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

fix(query): Prevent multiple entries for same predicate in mutations. #7715

Merged
merged 2 commits into from
Apr 12, 2021

Conversation

rohanprasad
Copy link
Contributor

@rohanprasad rohanprasad commented Apr 12, 2021

Multiple entries for the same predicate can lead to inconsistent state, hence adding an error for it instead.

Fixes DGRAPH-3225


This change is Reviewable

Copy link
Contributor

@ahsanbarkati ahsanbarkati left a comment

Choose a reason for hiding this comment

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

Awesome @rohanprasad. I would want similar check for types as well.

<name>: string .
<age>: int .
type <Person> {
  name
}
type <Person> {
  age
}

The above schema update should also complain. Currently we accept this schema.

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @pawanrawal)

Copy link
Contributor

@NamanJain8 NamanJain8 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 1 files reviewed, 1 unresolved discussion (waiting on @pawanrawal and @rohanprasad)


query/mutation.go, line 39 at r1 (raw file):

// isValidSchemaChange check if the mutation has valid schema changes. In case the mutation
// has multiple entries for the same predicate we error out.
func isValidSchemaChange(m *pb.Mutations) error {

Looks good. Just a comment.
Most of the cases for schema update are handled in parseSchemaFromAlterOperation. I think it would be better to make these checks there.

@rohanprasad
Copy link
Contributor Author

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @pawanrawal and @rohanprasad)

query/mutation.go, line 39 at r1 (raw file):

// isValidSchemaChange check if the mutation has valid schema changes. In case the mutation
// has multiple entries for the same predicate we error out.
func isValidSchemaChange(m *pb.Mutations) error {

Looks good. Just a comment.
Most of the cases for schema update are handled in parseSchemaFromAlterOperation. I think it would be better to make these checks there.

Done

Copy link
Contributor

@NamanJain8 NamanJain8 left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @manishrjain, @NamanJain8, @pawanrawal, and @vvbalaji-dgraph)

@rohanprasad rohanprasad merged commit 96407af into master Apr 12, 2021
@aman-bansal aman-bansal deleted the rohanprasad/fix_multi_mutation_schema branch April 12, 2021 11:54
dshekhar95 pushed a commit that referenced this pull request Aug 19, 2022
…a mutations. (#7715)

* fix(query): Prevent multiple entries for the same predicate/type in mutations.

Fixes DGRAPH-3225
dshekhar95 pushed a commit that referenced this pull request Sep 15, 2022
…a mutations. (#7715)

* fix(query): Prevent multiple entries for the same predicate/type in mutations.

Fixes DGRAPH-3225
dshekhar95 pushed a commit that referenced this pull request Sep 19, 2022
…a mutations. (#7715)

* fix(query): Prevent multiple entries for the same predicate/type in mutations.

Fixes DGRAPH-3225
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.

3 participants