-
Notifications
You must be signed in to change notification settings - Fork 352
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: use generated user name column for make query DB only [DHIS2-17200] #19294
Merged
Conversation
This file contains 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
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Restrictions.java
Show resolved
Hide resolved
...c/main/resources/org/hisp/dhis/db/migration/2.42/V2_42_32__User_name_as_generated_column.sql
Outdated
Show resolved
Hide resolved
david-mackessy
approved these changes
Nov 27, 2024
Not sure if we have any metrics, but it would be nice to know if this has a positive performance impact and by how much, or if it mainly simplifies things for us in code/query. |
Quality Gate passedIssues Measures |
netroms
approved these changes
Nov 27, 2024
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.
Summary
Makes the
User
name
property a generated column that is auto-composed fromfirstName
andsurname
in/by the DB.This makes
name
a persisted property wherebyquery=Xyz
also is a pure DB filter forUser
s.This is important to avoid the different terms in the OR clause generated from it to be split up between JPA and in-memory query because splitting would not result in the correct result as a filter like (A OR B OR C) AND X changes to (A OR B) AND X AND C (the OR bracket being created from the
query
parameter).As a bonus this also means
name
is now a usable property infilter
when using the Gist API.This PR also corrects the HBM mapping where
firstName
andsurname
. They were incorrectly marked as nullable when they always have beennot null
in the DB. That means these properties changed in the schema from being optional to now berequired
. This change caused a couple of tests to fail as they were not providing the required fields.This PR also fixes a bug in the "filter that always are false" detection. They only result in an empty list of filters are combined AND so this extra condition was added.
As a further improvement
query
will only add theid:eq:<query>
filter part if the<query>
string has 11 characters as it is otherwise impossible for this filter to match.Automatic Testing
Existing tests where adjusted. A new test scenario was added to verify that
name
can be used as Gist API filter.Manual Testing
/api/users?filter=name:like:xyz
(compare results to older versions)/api/users?query=name:like:xyz
(compare results to older versions)firstName
and/orsurname
of a user and check the change is automatically reflected in theirname