ternary nullness logic implementation #113
Closed
+1,042
−416
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.
https://jira.mongodb.org/browse/HIBERNATE-74
The most complex and challenging task in m3!
The following constraints are put into place for this PR:
find
expression is invovled (as discussed previously,$expr
is out of scope of m3)The basic idea is to exclude null fields preemptively to emulate HQL/SQL's ternary nullness logic for and only for
AstFieldOperationFilter
translation (AstLogicalFilter
won't be touched).for instance, the following is the original Mql translation result containing JDBC placeholder (as the
$match
aggregation stage) for thefrom Book where title = :title
HQL selection query):This PR will transform it as belows to exclude null title to emulate ternary logic
An example involving logical operator (corresponds to HQL:
... where country = :country and age > :age
):Note that we only replace file comparison expression with its nullness exclusion condition.
Why excluding null field during comparison could work? I give some reasons below:
or
operator; regardless it will end up with false and won't contribute to the record to be returned; excluding null fields preemptively ends up with the same retrieval result; in this sense it is an indirect emulation.Existing
SimpleSelectQueryIntegrationTests
integration testing cases will showcase the newnull-safe
Mql translation results for they contain resulting Mql validation logic.