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

Ensure same variable name is used in WHERE clause as in SELECT/FROM #124

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

vierbergenlars
Copy link
Member

Most of the time, QueryDSL PathBuilderFactory uses the same variable
name as in the generated Q* classes (which is used in select/from by
spring-data-rest using the EntityPathResolver). However, this breaks
down when an entity is used that would have a reserved keyword as simple
name.

In that case, the generated Q* class has a '1' appended to the
variable (to avoid using a reserved keyword), but the
PathBuilderFactory does not. (See
querydsl/querydsl#1891 for the rationale).

We must use the same strategy for naming our predicates as used by
spring-data-rest to make this work, so a Thunx PathBuilderFactory
interface is introduced, together with an implementation that creates a
PathBuilder based on the metadata from the spring-data-rest EntityPathResolver.

@vierbergenlars vierbergenlars requested a review from a team as a code owner August 16, 2023 11:11
@vierbergenlars vierbergenlars force-pushed the fix-predicates-for-reserved-keywords branch from ca5e3ab to b27a9e3 Compare August 16, 2023 11:17
Most of the time, QueryDSL `PathBuilderFactory` uses the same variable
name as in the generated `Q*` classes (which is used in select/from by
spring-data-rest using the `EntityPathResolver`). However, this breaks
down when an entity is used that would have a reserved keyword as simple
name.

In that case, the generated `Q*` class has a '1' appended to the
variable (to avoid using a reserved keyword), but the
`PathBuilderFactory` does not. (See
querydsl/querydsl#1891 for the rationale).

We must use the same strategy for naming our predicates as used by
spring-data-rest to make this work, so a Thunx `PathBuilderFactory`
interface is introduced, together with an implementation that creates a
`PathBuilder` based on the metadata from the spring-data-rest `EntityPathResolver`.
@vierbergenlars vierbergenlars force-pushed the fix-predicates-for-reserved-keywords branch from b27a9e3 to 7d0ab60 Compare August 16, 2023 11:18
@vierbergenlars vierbergenlars merged commit 10d4eaa into main Aug 16, 2023
2 checks passed
@vierbergenlars vierbergenlars deleted the fix-predicates-for-reserved-keywords branch August 16, 2023 11:35
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.

2 participants