fix invisible null constraints in sql_table #1660
Merged
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.
Thix PR fixes issue #1655
Diagram
Before
After
Summary
The behavior of null, when used in arrays, is now consistent with how other types work. When used as the only constraint (without array), only types which implement
d2ast.String
are allowed. Null is also allowed but does nothing, as expected. In arrays all types are allowed but booleans are converted to lower case. Null was previously converted to an empty string, this PR changes it to lower case string "null".This could also be fixed by changing return value of
ScalarString()
method forNull
type. I tried it and all tests pass, however there is this commit: 9d0c73cAnother solution would be to disallow everything but
d2ast.String
in constraint arrays, to keep it consistent with how non-array constraints work, however this could break existing diagrams and prevent them from compiling. Let me know if you would prefer this solution.