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

Method countQuery does not create select if where are line break characters (\n) #10617

Closed
xumk opened this issue Jul 9, 2020 · 3 comments · Fixed by #10656
Closed

Method countQuery does not create select if where are line break characters (\n) #10617

xumk opened this issue Jul 9, 2020 · 3 comments · Fixed by #10656
Labels
kind/bug Something isn't working
Milestone

Comments

@xumk
Copy link
Contributor

xumk commented Jul 9, 2020

I have base functional for create where string, it create string with line break characters (\n).

code:

PanacheQuery myEntityPanacheQuery = MyEntity.find(whereStr, whereParameters);

myEntityPanacheQuery.page(Page.of(pageNumber, pageSize)).list(); // it is good work

myEntityPanacheQuery.count(); // it is return exception

method count() is return exception:
io.quarkus.panache.common.exception.PanacheQueryException: Count query not supported for select query: FROM com.MyEntity WHERE field like :field and (1 = :value1 OR (field2 = :field2)) at io.quarkus.hibernate.orm.panache.common.runtime.CommonPanacheQueryImpl.countQuery(CommonPanacheQueryImpl.java:252) at io.quarkus.hibernate.orm.panache.common.runtime.CommonPanacheQueryImpl.count(CommonPanacheQueryImpl.java:214) at io.quarkus.hibernate.orm.panache.runtime.PanacheQueryImpl.count(PanacheQueryImpl.java:144) at com.bivgroup.soglacie.rra.service.journal.jra.WorkAgentJournalService.lambda$loadJournalResult$1(WorkAgentJournalService.java:39) at io.smallrye.mutiny.operators.UniMapOnResult$1.onItem(UniMapOnResult.java:31)
If remove line break characters from where string, when countQuery will be to work well.
I think FROM_PATTERN in CommonPanacheQueryImpl class it should be replaced Pattern.compile("^\\s*FROM\\s+.*", Pattern.CASE_INSENSITIVE); on Pattern.compile("^\s*FROM\s+(.|\n)*", Pattern.CASE_INSENSITIVE); or similar that patter processed line break characters (\n).

Quarkus version 1.5.2

@xumk xumk added the kind/bug Something isn't working label Jul 9, 2020
@gastaldi
Copy link
Contributor

gastaldi commented Jul 9, 2020

@xumk good catch, would you be interested in providing a pull-request (with a reproducer test)?

@xumk
Copy link
Contributor Author

xumk commented Jul 9, 2020

@gastaldi i could try

@fwgreen
Copy link

fwgreen commented Jul 11, 2020

I've had similar problems with Text Blocks but didn't open an issue because they are still a preview feature. Hopefully this fix will resolve those as well. Thanks for your work!

@gsmet gsmet added this to the 1.6.1.Final milestone Jul 16, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants