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 select distinct projection with Panache #29121

Merged
merged 2 commits into from
Nov 11, 2022

Conversation

DavideD
Copy link
Contributor

@DavideD DavideD commented Nov 8, 2022

Fix #29089

Copy link
Contributor

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Nov 8, 2022
@geoand
Copy link
Contributor

geoand commented Nov 8, 2022

Does this need to be backported to 2.14 and perhaps 2.13?

@loicmathieu
Copy link
Contributor

@geoand as it's a bug I vote for backporting it

@geoand
Copy link
Contributor

geoand commented Nov 8, 2022

Makes sense

@geoand
Copy link
Contributor

geoand commented Nov 8, 2022

CI doesn't seem to like it as quarkus-integration-test-hibernate-orm-panache is failing

@quarkus-bot

This comment has been minimized.

When trying to run a select distinct query with projection, Panache will
lowercase the field names.
@DavideD
Copy link
Contributor Author

DavideD commented Nov 10, 2022

It should be fixed now. Let's wait until CI agrees.

It's annoying that panache allows stuff like this:

find("select ... ", Parameters.with("param1", value), Sort.by("field"))

even if it's wrong.

@loicmathieu
Copy link
Contributor

@DavideD

It's annoying that panache allows stuff like this:

find("select ... ", Parameters.with("param1", value), Sort.by("field"))
even if it's wrong.

We can compute the list of entity fields at build time, inject it somewhere and check this list in all calls to Sort and Parameters. This will have a slight memory impact for storing the cache, not a lot, but adding the check in all possible place would be some work.

But is it really worth it ? Such error will pop up at developement time with a clear error message right ?

@DavideD
Copy link
Contributor Author

DavideD commented Nov 10, 2022

This really should be a compilation error.

But is it really worth it ?

Yes.

Such error will pop up at developement time with a clear error message right ?

No.
The error was something related to an additional parameter and it took me a lot of time to figure out that the Sort was the problem.
It delayed the fix by a couple of days. By comparison, the actual fix took me 20 minutes.

If somebody works an a project with unit tests that can be run quickly, this is not a big deal. But in the real world is not always the case.

This is something that a good API shouldn't allow.

@DavideD
Copy link
Contributor Author

DavideD commented Nov 10, 2022

To clarify, I don't mean that we have to change Panache right now (that's why I haven't created a separate issue for it).
But we already have classes to specify Parameters and Sort, it should be possible to make the API more robust.

@geoand geoand merged commit b0a1dea into quarkusio:main Nov 11, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Nov 11, 2022
@quarkus-bot quarkus-bot bot added this to the 2.15 - main milestone Nov 11, 2022
@loicmathieu
Copy link
Contributor

@DavideD if the error message is not explicit, then I agree we should investiguate to make the API more robust (if the cost is not too high).
Can you open an issue with a reproducer so we can discuss it ?

@gsmet gsmet modified the milestones: 2.15 - main, 2.14.1.Final Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panache project() is not working if used with distinct + case-sensitive HQL query
4 participants