Repository navigation
fail min facets on incomparable date and duration values - #132
Merged
Merged
Conversation
compareToGDate and compareToGDuration return 2 for an incomparable pair. The max facet checks already report that as invalid; the min checks let it through. Report it there too.
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.
Found while reading the bound checks in
JavaGDateHolderEx.validateValue.compareToGDateis documented to return 2 for an incomparable pair, and the four checks did not look like they agreed on what 2 means. Ran one bound against one value under each facet to see:The value has no timezone and sits within 14 hours of the bound, so the order is indeterminate. The max checks test
> 0and>= 0. 2 satisfies both, so the value is reported. The min checks test< 0and<= 0. 2 satisfies neither, so the value passes. It is not greater than or equal to the bound, so it should fail the min facets too.JavaGDurationHolderEx.validateValuehas the same shape and gives the same result: P1M against a bound of P30D validates under both min facets and is rejected under both max facets.The schema compiler already takes this view.
StscSimpleTypeResolverrefuses a derived bound whencomparison == 2.The fix reports 2 in the two min checks of each holder. Only values whose order against the bound is indeterminate change, and the max facets already reject those. The float, double, decimal and integer holders compare with a total order, so they are untouched.
Regression test added in
IncomparableMinFacetValidateTest. On trunk the two incomparable cases fail as above, with the fix all four pass, and./gradlew testis green.AI tooling was used to help prepare this change.