Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/deletes #215 #219

Merged
merged 2 commits into from
Nov 3, 2022
Merged

Feature/deletes #215 #219

merged 2 commits into from
Nov 3, 2022

Conversation

bplatz
Copy link
Contributor

@bplatz bplatz commented Nov 3, 2022

This addresses #215 and adds a deletion capability to Fluree which can leverage a query :where clause to define exact data to remove. This is a substantial increase in capability to current Fluree's delete capability which always requires one to know the subject being removed, and anything more complex than simple deletes can require compare and swap operations.

You can now issue the following as examples (see new tests for full detail)

Delete everything for a subject:

@(fluree/stage db
{:delete [:ex/alice '?p '?o]
 :where  [[:ex/alice '?p '?o]]})

Delete all values for a subject+predicate:

{:delete [:ex/bob :schema/age '?o]
 :where  [[:ex/bob :schema/age '?o]]}

What's completely new however is that you can target other information based on predicates + values:

Delete all subjects that have an email address:

{:delete ['?s '?p '?o]
 :where  [['?s :schema/email '?x]
          ['?s '?p '?o]]}

Delete all subjects who are 30 years old:

{:delete ['?s '?p '?o]
 :where  [['?s :schema/age 30]
          ['?s '?p '?o]]}

@bplatz bplatz requested a review from a team November 3, 2022 14:59
@bplatz bplatz changed the base branch from main to feature/index-apis November 3, 2022 15:01
Base automatically changed from feature/index-apis to main November 3, 2022 19:30
Copy link
Contributor

@cap10morgan cap10morgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall! A few questions / little things to address, but good to merge after that.

@@ -899,6 +899,18 @@
%)))]
(assoc select :spec spec*)))

(defn update-delete
"Updates a delete statement variables with final where clause positions of items."
[{:keys [s p o] :as delete} where {group-out-vars :out-vars, :as _group-by}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is group-by applicable to deleting?

{:select '?name
:where [['?s :schema/name '?name]]})
["Jane" "Bob"])
"Only Jane and Cam should be left in the db.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Jane and Cam/Jane and Bob/ ?

{:id :ex/bob,
:rdf/type [:ex/User],
:schema/name "Bob"})
"Only Jane and Cam should be left in the db.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be something like "Bob should no longer have an age."?

@bplatz bplatz merged commit ede8cde into main Nov 3, 2022
@bplatz bplatz deleted the feature/deletes branch November 3, 2022 19:31
@cap10morgan cap10morgan mentioned this pull request Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants