fluree / core

Fluree releases and public bug reports
0 stars 0 forks source link

Predicate values in an `@list` cannot be deleted #74

Open Jackamus29 opened 5 months ago

Jackamus29 commented 5 months ago

Description

Using fluree/server:latest on Jan 8th, 2024

where+delete and where+delete+insert transactions do not effectively delete facts stored with an @container value of @list.

Steps to reproduce

Create ledger

{
  "ledger": "list-delete-test",
  "@context": {
    "ex": "http://example.org/ns/",
    "ex:age": {
      "@container": "@list"
    }
  },
  "insert": [
    {
      "@id": "zeti",
      "ex:age": [97, 19, 97, 19, 97]
    }
  ]
}

Query Zeti

{
  "from": "list-delete-test",
  "@context": {
    "ex": "http://example.org/ns/",
    "ex:age": {
      "@container": "@list"
    }
  },
  "selectDistinct": { "?s": ["*"] },
  "where": {
    "@id": "?s",
    "ex:age": "?age"
  }
}

Delete age values

{
  "ledger": "list-delete-test",
  "@context": {
    "ex": "http://example.org/ns/",
    "ex:age": {
      "@container": "@list"
    }
  },
  "where": {
    "@id": "?s",
    "ex:age": "?age"
  },
  "delete": {
    "@id": "?s",
    "ex:age": "?age"
  }
}

Query Zeti again (expected: empty, actual: same result as before delete)

{
  "from": "list-delete-test",
  "@context": {
    "ex": "http://example.org/ns/",
    "ex:age": {
      "@container": "@list"
    }
  },
  "selectDistinct": { "?s": ["*"] },
  "where": {
    "@id": "?s",
    "ex:age": "?age"
  }
}
Jackamus29 commented 5 months ago

Note that, when using where+delete+insert with an @list, the previous values are not deleted and the new values are inserted successfully. This seems to be the cause of a user's issue reported via Discord: https://discord.com/channels/896089675511508992/1191042410755661834

aaj3f commented 5 months ago

If you pick this up, consider picking up fluree/core#75 as well (also related to @list)

Jackamus29 commented 4 months ago

Hey @dpetran - it looks like https://github.com/fluree/db/pull/720 did not solve this bug.

dpetran commented 4 months ago

Testing this on the db main branch (1fa39b74fa61deb3df1503060569395e86267fd1) seems to work correctly. Can you confirm the commit sha of the db version you were testing against?

aaj3f commented 4 months ago

@dpetran the behavior is seen on HEAD of main on server: 5f5ead9cbfbe25bf10f05a92f517cc0f392c0694 (which uses db git SHA 4b6a864587c4b75b7c7f0fd5de854ca65bea6570)

It wouldn't surprise me if the issue is in the back-and-forth (de)serialization of JSON data (but not sure if it's at the transaction time or query time), which is to say the issue may be more in server than in db (either before the txn is sent to db or after the query results are returned from db

dpetran commented 4 months ago

I've updated the server db dep version so it should be working now.

Jackamus29 commented 4 months ago

Hey again @dpetran - I just built a fresh Docker image from your latest fluree/server commit (HEAD of main) and I'm still seeing the inability to delete @list items as described in this bug ticket. Is there any additional information I can provide or tests I can try that would give you enough to reproduce?

dpetran commented 4 months ago

I've added some tests to verify that deletion is working correctly, and it seems to be. Is there a way to verify that the docker image was built correctly?