-
Notifications
You must be signed in to change notification settings - Fork 359
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
refactor: remove junctions from query engine API [DHIS2-18041] #20008
Conversation
...-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java
Fixed
Show fixed
Hide fixed
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java
Fixed
Show fixed
Hide fixed
@ToString | ||
public class Query { | ||
|
||
private final List<Restriction> filters = new ArrayList<>(); |
Check notice
Code scanning / CodeQL
Exposing internal representation Note
after this call to getFilters
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely catch spotting this 👍
Summary
Fixes special filters that would require junctions by moving their composition into the query engine.
While this refactoring removes nested junctions from the query engine API this does not remove a web API feature. Nested junctions were only used in a few special programmatic cases to build more sophisticated filters. Within the
Query
all filters are now just oneRestriction
. Sophisticated ones are expanded first within the engine making it unnecessary to model junctions on theQuery
orRestriction
level.To distinguish
Restriction
s that are simple from those that need expanding theisVirtual()
method got added encoding the few conditions where this is needed.Simplifications
Criteria
,Criterion
,Disjunction
andConjunction
as all filters are now simpleRestriction
sQuery
but extracted from theRestriction
in the JPA query engine when neededTyped
got replaced by simply usingList.of
Operator.collectionArgs
was replaced with usingOperator.args
instead (there never was a need for another field as only in/not-in operator would use it and they always would only have one list of args that could useargs
as all other operators)QueryPlanner.planQuery
withpersistedOnly
got removed (this was never necessary asQuery
instances passed to aQueryEngine
should always be already planned as they should come from within theQueryService
and never be passed to the engine directly)Locale
dependency for token filter within theTokenOperator
classCorrections
DefaultJpaQueryParser
got renamed toDefaultQueryParser
(wasn't specific to JPA in any way)QueryEngine
generic got removed (it was wrongly made generic when it was not)Operator
got changed from<T extends Comparable<? super T>>
to<T extends Comparable<T>>
(was too unspecific which forced some casts that now can be avoided)Cleanup
QueryPath
got moved into the schema module and is not computed by theSchemaService
(as it really as an extension onSchema
andProperty
that is only used forQuery
)QueryService.query
withResultTransformer
got removed (was unused)Operator.getHibernateCriterion
got removed (was unused)