Skip to content

Help with Update with multiple values and where clauses. #43

Open
@jk89

Description

@jk89
async def test_update():
    prepared = await self.scylla.prepare(updateCql)
    return await self.scylla.execute(prepared, templates)

My updateCql looks like this:

UPDATE TestEntity
SET name = ?, name_metadata = ?
WHERE partition_key = ? and clustering_key = ?

My templates look like:

['A New Name', '{"created_at": "2024-02-29T01:48:11.762650", "author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "lasted_edited_at": "2024-02-29T01:48:11.776834", "last_author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "last_session_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103"}', '3cd9d45f-846e-4490-b078-856cde633784', '28757173-254b-4a75-ab66-52cddf0b5c23']

The result:

python3.10/site-packages/rx/core/observable/fromfuture.py", line 29, in done
    value = future.result()
asyncio.exceptions.CancelledError

Expected entity gets updated.

I've looked through the tests and there is only one Update example but it does not have multiple where clauses nor multiple values being inserted at the same time.

I also tried to use the query builder however i need to set multiple keys and it does not like it when where clauses are appended programmatically. Ive got a similar example for INSERT and it works fine...

INSERT INTO TestEntity (clustering_key, clustering_key_metadata, name, name_metadata, partition_key, partition_key_metadata, other, other_metadata)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)

['28757173-254b-4a75-ab66-52cddf0b5c23', '{"created_at": "2024-02-29T01:48:11.762740", "author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "lasted_edited_at": "2024-02-29T01:48:11.762740", "last_author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "last_session_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103"}', 'Bob', '{"created_at": "2024-02-29T01:48:11.762650", "author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "lasted_edited_at": "2024-02-29T01:48:11.762650", "last_author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "last_session_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103"}', '3cd9d45f-846e-4490-b078-856cde633784', '{"created_at": "2024-02-29T01:48:11.762720", "author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "lasted_edited_at": "2024-02-29T01:48:11.762720", "last_author_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103", "last_session_id": "192.168.0.76:26326608-77a8-447b-8c29-692333f80103"}', '{}', '{"created_at": null, "author_id": null, "lasted_edited_at": null, "last_author_id": null, "last_session_id": null}']

return await self.scylla.execute(insertCql, columnValues)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions