Replace attribute-to-attribute comparison with constant for cross-datastore portability#1327
Replace attribute-to-attribute comparison with constant for cross-datastore portability#1327otaviojava wants to merge 5 commits intomainfrom
Conversation
…e for numBitsRequired
…e for numBitsRequired
njr-11
left a comment
There was a problem hiding this comment.
While the original expression works in SQL, it is not reliably supported across NoSQL providers and may bypass indexes or trigger full scans.
The test is not written to use SQL. It is written to rely on JCQL, which allows the pattern,
comparison_expression : scalar_expression comparison_operator scalar_expression;
As currently written, the Jakarta Data spec allows Key-Value and Wide-Column to raise UnsupportedOperationException, and those two database types are exactly what the TCK test checks for and skips the test already. If there are additional allowances needed for Document and/or Graph, please let me know, and we can add wording to the specification to make it valid to skip the test for those as well.
I do not agree with changing the test to avoid the scenario entirely. It is valid usage of JCQL and ought to be tested for the database types that are capable of it.
|
@njr-11 thanks for the clarification — I agree with you on the formal reading of the spec. Yes, JCQL explicitly allows scalar_expression comparison_operator scalar_expression, and historically this grammar is clearly inspired by SQL and Jakarta Persistence. No disagreement there. Even for Document and Graph databases, WHERE a = b is not uniformly supported or guaranteed to behave consistently. In practice, support varies significantly between providers, and index usage is often undefined or unavailable. From a user perspective, this makes the behavior effectively provider-dependent. Given this reality for NoSQL providers, how does the specification intend to define the portability expectations for a = b comparisons? |
I proposed a spec update for this under #1329 . Please review and let me know if you would like the wording adjusted. |
|
Thank you @njr-11 I am totally fine with this option as well. Thus, I will close this PR. |
This change replaces an attribute-to-attribute comparison in a Jakarta Query predicate with a constant value.
While the original expression works in SQL, it is not reliably supported across NoSQL providers and may bypass indexes or trigger full scans.
Using a constant ensures consistent semantics, predictable performance, and portability across SQL and NoSQL implementations.