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

Remove use of casts in SQL queries #166

Open
elliVM opened this issue Dec 19, 2024 · 0 comments
Open

Remove use of casts in SQL queries #166

elliVM opened this issue Dec 19, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@elliVM
Copy link
Contributor

elliVM commented Dec 19, 2024

Describe the bug
Jooq generated queries sometimes use cast when building Java resulting SQL with casts. Example case SQL
join on bloomdb.filtertype.id = cast(bloomdb.uuid_table.filter_type_id as unsigned)

Better solution would be to type check in Java and not cast in SQL.

example of a cast in jooq that should be replaced
(JOURNALDB.LOGFILE.ID.eq((Field<ULong>) table.field("partition_id"))

Expected behavior
No casts should be used

How to reproduce
Present in bloom filter queries for example when filter table is left joined to main query.

Software version
3.3.3

Additional context
Dynamic table field types are not know beforehand by jooq. Type must be assigned in Java, couple of solutions:

  1. Construct a field with a type by yourself DSL.field("id", ULong.class);
  2. Construt a typed field from current table table.field("id", ULong.class);

This should move type checking to java but include tests that casts are not present in SQL.

@elliVM elliVM added the bug Something isn't working label Dec 19, 2024
@elliVM elliVM self-assigned this Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant