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

HHH-16858 improve typechecking for comparisons/assignments #6910

Merged
merged 3 commits into from Jun 28, 2023

Conversation

gavinking
Copy link
Member

@gavinking gavinking commented Jun 28, 2023

In particular, correctly type check comparisons between enums and other enums, literal integers, and literal strings.

Actually I'm not a great fan of comparing enums with int/string literals but since we used to support it in 5, and kinda mostly support it in earlier releases of 6, on balance we might as well continue to allow it. It's not like it's wrong wrong, just something that's probably bad most of the time.

Indeed, this patch goes so far as to allow this sort of comparison in general when JDBC types match in a "reasonable" way. Where "reasonable" involves some handwavey heuristics. Not perfect but I guess this probably a case where worse is better.

UPDATE: I was also obligated to "fix" the non-bug HHH-16859 by side-effect of cleaning up another issue with type-checking of enum function args. Once again, I'm really not sold that max(enum) is a great thing to write, but given that we used to allow it, it's pretty hard for me to justify inserting new code to specifically disallow it.

In particular, correctly typecheck comparisons between enums
and other enums, and literal integers / strings. Actually
I'm not a great fan of comparing enums with int/string literals
but since we used to support it in 5, and kinda mostly support
it in earlier releases of 6, on balance we might as well continue
to allow it.
- use the known JdbcType which previously we didn't have
  proper access to
- and accidentally fix HHH-16859 by side-effect
  (I didn't really want to fix that one, but it was easier
  to fix it than to unfix it.)
@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Jun 28, 2023

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [0e28b24]

› This message was automatically generated.

@gavinking gavinking merged commit 1e4b9e8 into hibernate:main Jun 28, 2023
18 of 19 checks passed
@gavinking gavinking deleted the comparison-typechecking branch July 5, 2023 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant