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: use generated user name column for make query DB only [DHIS2-17200] #19294

Merged
merged 7 commits into from
Nov 27, 2024

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Nov 26, 2024

Summary

Makes the User name property a generated column that is auto-composed from firstName and surname in/by the DB.

This makes name a persisted property whereby query=Xyz also is a pure DB filter for Users.
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 in filter when using the Gist API.

This PR also corrects the HBM mapping where firstName and surname. They were incorrectly marked as nullable when they always have been not null in the DB. That means these properties changed in the schema from being optional to now be required. 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 the id: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

  • filter users by name /api/users?filter=name:like:xyz (compare results to older versions)
  • filter by query /api/users?query=name:like:xyz (compare results to older versions)
  • update firstName and/or surname of a user and check the change is automatically reflected in their name

@jbee jbee marked this pull request as ready for review November 27, 2024 09:40
@david-mackessy
Copy link
Contributor

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.

Copy link

sonarcloud bot commented Nov 27, 2024

@jbee jbee merged commit 0167196 into master Nov 27, 2024
15 checks passed
@jbee jbee deleted the DHIS2-17200-fixes2 branch November 27, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants