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

Add support for conditional mutations #50

Closed
wants to merge 4 commits into from

Conversation

srfrog
Copy link
Contributor

@srfrog srfrog commented Mar 28, 2019

This PR adds initial API support for conditional mutations (txn block).

New mutation signature:

txn {
  # conditional query that yields a var(s)
  query {
    # ...
  }
  # mutation that depends on query above and may use var values
  mutation {
    # ...
  }
}

Breaking changes:

  • New API field cond_query in Mutation gRPC message for sending conditional query.
  • New API field subject_var in NQuad gRPC message to indicate variable name instead of subject uid
  • New API field object_var in NQuad gRPC message to indicate variable name instead of object id

An example of proper usage is also included.


This change is Reviewable

Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @srfrog)


example_mutation_txn_test.go, line 1 at r1 (raw file):

/*

Maybe move this file and the rest of the examples to a separate directory?


protos/api.proto, line 134 at r1 (raw file):

Value var_name = 8;

How is this field supposed to be used? I do not see it in the example.

Copy link
Contributor Author

@srfrog srfrog left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @martinmr)


example_mutation_txn_test.go, line 1 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

Maybe move this file and the rest of the examples to a separate directory?

Sure, but maybe not for this particular PR.


protos/api.proto, line 134 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…
Value var_name = 8;

How is this field supposed to be used? I do not see it in the example.

VarName has the name of the query variable for this nquad. When assigning uids before mutation, we use the value from the variable to alias the subject. Similar to _: but the inverse.

See https://github.com/dgraph-io/dgraph/pull/3197/files#diff-e9752ad411f442cb414981895be0a228R153

@srfrog srfrog marked this pull request as ready for review April 4, 2019 18:35
Copy link

@gitlw gitlw left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @martinmr)

@martinmr
Copy link
Contributor

martinmr commented Apr 4, 2019

Your examples are being run right now by the integration tests and failing. I would either disable the tests for now or revert them and re-add them once they can pass. It's fine if this PR only includes the API changes.

Copy link
Contributor Author

@srfrog srfrog left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @martinmr)


example_mutation_txn_test.go, line 1 at r1 (raw file):

Previously, srfrog (Gus) wrote…

Sure, but maybe not for this particular PR.

Done.

Copy link

@gitlw gitlw left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @martinmr)

Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@mangalaman93 mangalaman93 deleted the srfrog/add_mutation_txn branch March 22, 2023 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants