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

Disallow uid as a predicate name. #4219

Merged
merged 3 commits into from
Nov 4, 2019
Merged

Conversation

martinmr
Copy link
Contributor

@martinmr martinmr commented Oct 25, 2019

uid is used internally to report the UIDs of the nodes in Dgraph. Users
should get an error when trying to add a predicate of that name to the
schema or when sending mutations with uid as a predicate.

This PR enables checks for those situations.


This change is Reviewable

uid is used internally to report the UIDs of the nodes in Dgraph. Users
should get an error when trying to add a predicate of that name to the
schema or when sending mutations with uid as a predicate.

This PR enables checks for those situations.
@martinmr martinmr requested review from manishrjain and a team as code owners October 25, 2019 23:32
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ A review job has been created and sent to the PullRequest network.


@martinmr you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

These changes look pretty solid. Nothing to comment on.


Reviewed with ❤️ by PullRequest

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✖️ This code review was cancelled. See Details

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @manishrjain)

Copy link
Contributor

@poonai poonai 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: all files reviewed, 3 unresolved discussions (waiting on @manishrjain and @martinmr)


worker/draft.go, line 255 at r1 (raw file):

	for attr, storageType := range schemaMap {
		if _, err := schema.State().TypeOf(attr); err != nil {

do we need any explicit error checking? createSchema if this error


worker/mutation.go, line 210 at r1 (raw file):

		return err
	}
	if err := updateSchema(&s); err != nil {

Just return updateSchema(&s)


x/keys.go, line 565 at r1 (raw file):

// predicate is a predicate that has a special meaning in Dgraph and its query
// language and should not be allowed as a user-defined  predicate.
var internalPredicateMap = map[string]struct{}{

where predicates are populated?

Copy link
Contributor Author

@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: all files reviewed, 2 unresolved discussions (waiting on @balajijinnah and @manishrjain)


worker/draft.go, line 255 at r1 (raw file):

Previously, balajijinnah (balaji) wrote…

do we need any explicit error checking? createSchema if this error

I changed the return value of createSchema so I changed the code here to check for that error.


worker/mutation.go, line 210 at r1 (raw file):

Previously, balajijinnah (balaji) wrote…

Just return updateSchema(&s)

Done.


x/keys.go, line 565 at r1 (raw file):

Previously, balajijinnah (balaji) wrote…

where predicates are populated?

Right here. This is meant to act as a constant. The map should not modified. If another predicate (let's say _predicate_ is deemed as an internal predicate, it should be added here.

Copy link
Contributor

@poonai poonai left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 5 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @balajijinnah and @manishrjain)

@martinmr martinmr merged commit 11ccd73 into master Nov 4, 2019
@martinmr martinmr deleted the martinmr/no-uid-user-predicate branch November 4, 2019 20:22
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