Skip to content

Query methods with isTrue/isFalse predicates do not work with Oracle #1090

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

Closed
cedric-schaller opened this issue Nov 17, 2021 · 3 comments
Closed
Assignees
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Comments

@cedric-schaller
Copy link

Query methods in repositories such as findByAvailableIsTrue() are converted to SQL statements with where parts like ("SOME_TABLE"."AVAILABLE" = TRUE). This is fine for many databases, but Oracle has no boolean type and people typically use the type NUMBER(1) instead. In such a case, the predicate should correctly translate to ("SOME_TABLE"."AVAILABLE" = 1).

The reason for this erroneous translation is located in org.springframework.data.relational.core.sql.render.ExpressionVisitor, which in our case calls the toString() method of the org.springframework.data.relational.core.sql.BooleanLiteral to compute the value of the expression (TRUE), despite the fact that the documentation of the toString() method of the org.springframework.data.relational.core.sql.Segment interface (which BooleanLiteral implements) explicitly states that

While it might work in the context of a specific dialect, you should not that the toString() representation works across multiple databases. (sic)

A possible solution would be to extend org.springframework.data.relational.core.dialect.Dialect with a

BooleanComparison booleanComparison()

method that would then be implemented in OracleDialect.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 17, 2021
@schauder
Copy link
Contributor

Related: #908

@schauder
Copy link
Contributor

Do you use the latest version of Spring Data JDBC(2.3)?
This seems indeed to be fixed with #908.
If it isn't please provide a reproducer.

Thanks for pointing the typo in the docs.

schauder added a commit that referenced this issue Nov 17, 2021
schauder added a commit that referenced this issue Nov 17, 2021
schauder added a commit that referenced this issue Nov 17, 2021
@schauder schauder self-assigned this Nov 17, 2021
@schauder schauder added the status: waiting-for-feedback We need additional information before we can continue label Nov 17, 2021
@cedric-schaller
Copy link
Author

After testing the whole thing again with Spring Boot 2.6.0 (which came out on Thursday), I can confirm that the problem is fixed with Spring Data JDBC 2.3. @schauder Thanks for the hint!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants