Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the unsafe nullability and unique analysis for ORDER BY expressions #418

Closed
beikov opened this issue May 18, 2017 · 1 comment · Fixed by #611
Closed

Fix the unsafe nullability and unique analysis for ORDER BY expressions #418

beikov opened this issue May 18, 2017 · 1 comment · Fixed by #611

Comments

@beikov
Copy link
Member

beikov commented May 18, 2017

Keyset pagination and optimizations regarding null precedence emulation depend on a working nullability and unique analysis of expressions.

Currently the analysis assumes that the owner of a path expression is non-optional i.e. rows are always produced for an alias. This is wrong and results in not being able to report unsafe use of ORDER BY items for keyset pagination. The nullability analysis might be wrong as it could report expressions being non-nullable because of the non-optional owner assumption. This leads to WHERE predicates for the keyset pagination that don't correctly handle nulls.

When the nullability analysis is fixed, we can also avoid generating null precedence handling for ORDER BY items.

Detecting nullability should be pretty simple. A path is nullable if the attribute is optional or one of the attributes parents in the join graph is optional. For *ToOne relations, a join node is optional if the FK is nullable. In general, relations are considered optional if they are left joined with a condition. Inner joined relations are always considered non-optional. A query root is always considered being an inner joined relation. Cross joined relations are also always non-optional.

A path is unique if the attribute is unique and the parents are all relations where a unique constraints can be inferred from the join predicate. Inner joins on one-to-one relations are always considered unique. Left joined relations are always considered non-unique as they could produce null values. Cross joined relations are always considered non-unique.

@beikov
Copy link
Member Author

beikov commented Sep 25, 2017

Note that it should also be possible to infer uniqueness when only *ToOne relations are joined from a root and the projections are based off that joined relation. This is the case when using e.g. an entity view with a custom view root.

@beikov beikov added this to the 1.2.0 milestone Nov 14, 2017
@beikov beikov modified the milestones: 1.2.0, 1.3.0, 1.6.0 Jan 28, 2018
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 22, 2018
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 22, 2018
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 25, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 25, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 25, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 27, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 30, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 30, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Jul 31, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Aug 1, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Aug 1, 2018
…nce handling when order by item is not nullable. Fixes Blazebit#418. Fixes Blazebit#569. Fixes Blazebit#194
beikov added a commit to beikov/blaze-persistence that referenced this issue Aug 1, 2018
…y null precedence handling when order by item is not nullable
beikov added a commit that referenced this issue Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment