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

Strict Mode - Only allow creation of predicates set in schema #2277

Closed
vespertilian opened this issue Mar 28, 2018 · 3 comments
Closed

Strict Mode - Only allow creation of predicates set in schema #2277

vespertilian opened this issue Mar 28, 2018 · 3 comments
Assignees
Labels
kind/enhancement Something could be better. priority/P1 Serious issue that requires eventual attention (can wait a bit)

Comments

@vespertilian
Copy link

From this forum thread: Dgraph forum

Feature idea: Strict mode for DGraph that would only allow the creation of predicates that have already been added via SetSchema.

Reason: Strict mode is a useful feature to take advantage of the type safety the schema can provide, preventing accidentally adding predicates with typos and improving the developer experience.

@manishrjain manishrjain added the kind/enhancement Something could be better. label Mar 29, 2018
@manishrjain manishrjain added this to the No Deadline milestone Mar 29, 2018
@fletcherist
Copy link

Hello guys! Just interesting... are there any practises how to avoid predicates not defined in schema? Strict mode could handle this cases very easily, but if it's not implemented yet, how do you solve this issue?

@srfrog
Copy link
Contributor

srfrog commented Nov 18, 2018

No, Dgraph is designed to take the data as the user sends it. And only applying type values when a schema exists. The default type is string so anything without type is assumed as string. We tested a type-hinting feature that is almost the inverse of strict types but it was not well received - https://discuss.dgraph.io/t/testing-mutation-type-changes/3352

I personally think strict schema mode would be great as it will simplify a lot of client-side logic, not to mention help with performance and memory use. So if strict mode is something the community wants to add to Dgraph we welcome any patches or design ideas to make it happen.

@manishrjain
Copy link
Contributor

This should be a simple change at our end. If a user has set strict schema checking, with a flag, we just don't accept a mutation unless the predicate already has a schema.

@manishrjain manishrjain added the priority/P1 Serious issue that requires eventual attention (can wait a bit) label Nov 18, 2018
@manishrjain manishrjain assigned martinmr and codexnull and unassigned martinmr Dec 20, 2018
dna2github pushed a commit to dna2fork/dgraph that referenced this issue Jul 19, 2019
Fixes dgraph-io#2277.

* Add --mutations option.

* Check strict mode and schema before allowing mutation.

* Remove --nomutations option.

* Add tests of strict schema with multi-group cluster.

* Refactor out code duplicated in proposeOrSend() and Mutate().

* Log message when server is ready to accept requests.

* Check for error instead of predicate type to detect undefined predicates.

* Replace nomutations test with mutations_mode test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Something could be better. priority/P1 Serious issue that requires eventual attention (can wait a bit)
Development

No branches or pull requests

6 participants