fix round-trip compound ids with a null segment#2717
Closed
lsmith77 wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
I guess I will close this. NULLable columns should just not be part of a compound identifier. |
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.
Fixes #2716
RestApiHandlerserializes a null segment of a compound id as an emptystring (
makeCompoundIdjoins the segments), emitting ids like200-01|for a record whose optional id field is null. But
coercethen runs thatempty segment through type coercion on parse (
parseInt('') → NaN → 400),so the handler rejects the very id it just emitted — any model with a
nullable field in its external/compound id has rows unaddressable by their
own id.
Fix:
coercegains anemptyAsNullflag, passed only from the id-parsingpaths (
makeIdFilter,makeIdConnect). An empty segment for an optionalfield now parses as
null(matched viaIS NULL), mirroring serialization.Filter-value coercion is unchanged.
Known limitation: an empty trailing/middle segment is ambiguous — an optional String field with the actual value "" serializes identically to null, so on parse it always resolves to null. (Numeric/Boolean/etc. types are unaffected: "" was never a valid value there, so the only thing an empty segment can mean is null.) This PR picks "null wins" as the simplest unambiguous rule.
We could explore other options:
Obviously the entire
NULLcase could also be rejected because it doesn't gurantee uniqueness.