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

Comparison predicates and quantified comparison predicates should hint array type to org.jooq.impl.Array for empty expression array casts #15982

Closed
lukaseder opened this issue Dec 22, 2023 · 1 comment

Comments

@lukaseder
Copy link
Member

Due to erasure, we can't know what the type of a generic expression array is:

SQLDialect dialect = SQLDialect.POSTGRES;

Field<String>[] fields = new Field[0];
println(DSL.using(dialect).render(array(fields)));
println(DSL.using(dialect).render(any(array(fields))));
println(DSL.using(dialect).render(val("x").eq(any(array(fields)))));
println(DSL.using(dialect).render(array("x").eq(array(fields))));

This currently prints:

cast(array[] as int[])
any (cast(array[] as int[]))
false
array[?] = cast(array[] as int[])

The int[] casts are wrong, they're just a historic default from org.jooq.impl.Array (probably text[] would have been a better default, as PostgreSQL tends to use text as a default data type, occasionally).

The third result is due to a regression in our implementation of quantified comparison predicates, see:

After fixing #15980, we'll get:

cast(array[] as int[])
any (cast(array[] as int[]))
? = any (cast(array[] as int[]))
array[?] = cast(array[] as int[])

But in all cases, we know the comparison expression's left hand side's type, so we could hint it to the right hand side, as we often do.

3.20 Other improvements automation moved this from To do to Done Dec 22, 2023
lukaseder added a commit that referenced this issue Dec 22, 2023
[(SELECT ARRAY ['x'])]) style quantified comparison predicate on multi
dimensional arrays

This includes:

- [#15982] Comparison predicates and quantified comparison
predicates should hint array type to org.jooq.impl.Array for empty
expression array casts
lukaseder added a commit that referenced this issue Dec 22, 2023
[(SELECT ARRAY ['x'])]) style quantified comparison predicate on multi
dimensional arrays

This includes:

- [#15982] Comparison predicates and quantified comparison
predicates should hint array type to org.jooq.impl.Array for empty
expression array casts
lukaseder added a commit that referenced this issue Dec 22, 2023
[(SELECT ARRAY ['x'])]) style quantified comparison predicate on multi
dimensional arrays

This includes:

- [#15982] Comparison predicates and quantified comparison
predicates should hint array type to org.jooq.impl.Array for empty
expression array casts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant