docs: state varchar/char defaults to '' as a rule, not a preference - #271
Open
dimitri-yatsenko wants to merge 2 commits into
Open
docs: state varchar/char defaults to '' as a rule, not a preference#271dimitri-yatsenko wants to merge 2 commits into
dimitri-yatsenko wants to merge 2 commits into
Conversation
NULL and '' both read as "nothing," and allowing both on a string attribute forces every query and make() body to handle two representations of the same absence. Surfaced by a live example in datajoint-python#1548, whose own new test fixtures defaulted varchar attributes to NULL.
An enum's closed value set is exactly the place to add '' as an explicit member rather than reaching for NULL — no reason to layer a second absence-mechanism on a type that already enumerates its allowed values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
`definition-syntax.md` already showed `''` as the preferred string default, but phrased the guidance as "prefer" — soft enough that it reads as stylistic rather than enforceable. Strengthens it into a stated rule with the reasoning: `NULL` and `''` both read as "nothing," so allowing both on the same attribute forces every query and every `make()` body to handle two representations of the same absence.
Surfaced by a live example: `datajoint-python#1548`'s own new test fixtures defaulted `varchar` attributes to `NULL` rather than `''`.