-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
containsIgnoreCase() behaviour change (maybe regression) #16659
Comments
Thank you for your report. When doing this: System.out.println(fieldNumeric.containsIgnoreCase("test")); Is there any expectation with respect to the exact generated SQL? The expression has no If you want to render an expression in the context of a There's a long-running "epic" task that attempts to simplify all of the rendered SQL in order to remove emulations from the This would explain why there was a change. Does your actual code also depend on |
Sorry if the report caused confusion because of being incomplete or misleading. I am not sure how the behaviour should be, I just noted that in older versions, our code "worked", and in newer versions, the semantic of the generated code changed drastically, and it may not have been intended (I looked into the source code and I think the change stems from additional type conversions taking place under the hood). |
Sure, that's what I assumed, and thus I asked what your actual code looks like. Because if it uses So, if there's another example that doesn't use |
Including, if you think that jOOQ's internals call |
Ok, i rewrote the simple example to better illustrate the change, and also, that it does rely on neither toString() nor a specific SQLDialect:
Output with jooq 3.11.5:
Output with jooq 3.19.8:
EDIT: I can not easily test this with the oracle dialect, as we are still using java 8, and to use the current jooq pro I would have to download pro versions I currently don't use etc. But the rendered SQL (with the "null" where "'test'" was before) is the same; I found the issue by debugging the real application and inspecting the executed SQL. |
I see now what you mean. The issue here is that in a comparison Normally, you'll get a compilation error because To be honest, I'm not really sure what to do with this now. What would be a use-case of calling |
I don't think there's a single issue for this kind of change. But it's an expectation that users keep having for various jOOQ API. An example of such a change / fix is this: It's mostly related to when These things always assume that type safety applies first, which it normally does. Given your example uses rawtypes, I'm assuming you're doing some dynamic SQL where arbitrary fields can be compared with arbitrary values and arbitrary operators? In that case, I do believe it would be good to prevent certain combinations that don't really make sense. Of course, it would be possible to take into account the possibility of purely string based operations being applied to non-string columns, but that would be a vast change throughout the jOOQ API, and would again lead to behavioural change similar to this one. I'm not sure if it's worth it... |
In our application, we have a "search all columns" text box on a lot of tables the application displays. Naturally, the user will want to search for quote numbers starting with "52" and things like that. So the conditions are generically generated for all columns. As I said, we do not need to rely on this "feature". We can check the column type and build fitting conditions correspondingly. Our original code probably originates from the fact that In the end, I think you will have to decide how jooq should behave in this case. |
An additional thought: Right now, there is SQL generated that executes, but definitely does not as intended. Maybe at least there should be a warning or an error in this case; however, I am not sure that is easily achievable. |
It's not valid in all RDBMS. E.g. in PostgreSQL: select 1234 like '%23' This produces:
I'll definitely have to think about this a bit more. Apart from the regression in your case, there are some things to consider:
Yes, there's a known issue where these implicit conversions of bind values and other things should throw instead of silently return See also: |
Expected behavior
When updating an outdated application from Jooq 3.11.5 to Jooq 3.19.8 (I know, I know), I found that the method
containsIgnoreCase()
behaves differently on numeric fields now.With 3.11.5, the behaviour was like this (varchar field is only for comparison, as it works as expected):
Actual behavior
With 3.19.8 (and also versions before that, did not check exactly since when), it does no longer work for numeric fields, as the rendered SQL is now this:
(which is ok for the varchar field of course), and
which is always true at least for Oracle databases, and does generally not work as before .
It is debatable wether it should work like it did before, so I leave it up to discussion if is is a bug/regression or not (background: in the application, it is used for query generation where the uses tables and columns are not known at compile time. It is certainly possible to check for types before blindly using
containsIgnoreCase()
)Steps to reproduce the problem
Execute the code snippet
with a current jooq version.
jOOQ Version
jooQ 3.19.8
Database product and version
No database used for the demonstration.
Java Version
8 and 17
JDBC / R2DBC driver name and version (include name if unofficial driver)
The text was updated successfully, but these errors were encountered: