Closed frydj closed 1 month ago
This was with a docker build of fluree-server
at commit 1bcae4ed161bd9b5f43a22f6d4f7e69a3a2737e0
The issue here is that the where
clause won't be applied as part of the where
clause is trying to assert based on values which aren't present, so it gets dropped (as I understand). So in order to do insert/where/delete when you aren't sure if there's a value on a predicate, you should use optional
, as in this example:
{
"ledger": "test123",
"insert": [
{
"@id": "ex:betty",
"schema:name": "Letty",
"schema:description": "This is the description"
}
],
"where": [
{
"@id": "ex:betty",
"schema:name": "?name"
},
[
"optional",
{
"schema:description": "?description"
}
]
],
"delete": [
{
"@id": "ex:betty",
"schema:name": "?name",
"schema:description": "?description"
}
]
}
You can also do something along the lines of:
"where": { "@id": "ex:betty", "?prop": "?val" },
"delete": { "@id": "ex:betty", "?prop": "?val" },
"insert": { ... whatever you want }
This would just be a way of deleting any facts on the subject, and inserting new ones. So this example isn't really a neat "edit" as much as a rip & replace of the facts on a subject.
See example below:
create the ledger with an entity "ex:betty"
Transaction:
Response:
query for betty
Query:
Response:
use insert/where/delete to update some facts about betty
Transaction:
Response:
query for betty again
Query:
Response:
update some existing facts again
Transaction:
Response:
query again
Query:
Response:
insert/where/delete again on a field which doesn't have values yet
Transaction:
Response
query again for betty values
Query:
Response:
it appears that when doing insert/where/delete where you include values which don't exist yet causes this unwanted insertion of multiple values (?)