sqlite doesn't respect composite primary keys?
parent
6053808218
commit
4a02fa2757
|
|
@ -72,7 +72,7 @@ CREATE TABLE `DataBlock` (
|
|||
`id` TEXT NOT NULL,
|
||||
-- id of the owner of this file. Ownership is not transferable because ids may collide,
|
||||
-- but the owner could be null for global scope
|
||||
`owner_id` TEXT NOT NULL DEFAULT 'none',
|
||||
`owner_id` TEXT,
|
||||
`visibility` TEXT CHECK( `visibility` IN ('public','private','unlisted') ) NOT NULL DEFAULT 'public',
|
||||
-- This is an indexable field to filter out different types of datablocks
|
||||
`category` TEXT,
|
||||
|
|
|
|||
|
|
@ -264,9 +264,19 @@ def set_data(request: fastapi.Request, data: dict, key: str = None, owner: str =
|
|||
|
||||
# add the data to the db
|
||||
db.insert("""
|
||||
REPLACE INTO `DataBlock` (id, category, modified_by, data, last_modified)
|
||||
VALUES(:id, :category, :modified_by, :data, CURRENT_TIMESTAMP);
|
||||
""", {"id": key, "category": category, "modified_by": modified_by, "data": json.dumps(data)})
|
||||
REPLACE INTO `DataBlock` (id, owner_id, category, modified_by, data, last_modified)
|
||||
VALUES(:id, :owner_id, :category, :modified_by, :data, CURRENT_TIMESTAMP);
|
||||
""", {"id": key, "owner_id": owner, "category": category, "modified_by": modified_by, "data": json.dumps(data)})
|
||||
|
||||
# # add the data to the db
|
||||
# db.insert("""
|
||||
# REPLACE INTO `DataBlock` SET
|
||||
# category = :category,
|
||||
# modified_by = :modified_by,
|
||||
# data = :data,
|
||||
# last_modified = CURRENT_TIMESTAMP
|
||||
# WHERE id=:id AND owner_id = :owner_id;
|
||||
# """, {"id": key, "category": category, "modified_by": modified_by, "owner_id": owner, "data": json.dumps(data)})
|
||||
|
||||
return {'key': key}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue