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

UPDATE .. SET ROW (..) = ROW (..) should coerce data types of argument rows #13270

Open
lukaseder opened this issue Mar 14, 2022 · 1 comment

Comments

@lukaseder
Copy link
Member

Just as with ROW comparisons (see #8517), a ROW update statement should coerce data types of argument rows if possible. For example:

assertEquals(1,
create().update(TAuthor())
        .set(row(TAuthor_FIRST_NAME()), row((String) null))
        .where(TAuthor_ID().equal(1))
        .execute());

This seems to fails with (see report here: https://groups.google.com/g/jooq-user/c/OtOqBK8_leM):

Caused by: java.lang.IllegalArgumentException: Cannot encode null parameter of type java.lang.Object
	at io.r2dbc.postgresql.codec.DefaultCodecs.encodeNull(DefaultCodecs.java:184)

I couldn't reproduce the problem with JDBC.

The row((String) null) expression should explicitly receive the row(TAuthor_FIRST_NAME())'s data types


See also:
https://groups.google.com/g/jooq-user/c/OtOqBK8_leM

@lukaseder
Copy link
Member Author

Hmm, trying to fix this, it seems that our internal conversion utility and org.jooq.impl.ConvertedVal doesn't work for this case. But I'm not convinced we can get this right.

The intention of row((String) null) seems to be to create a row of type String without any converter or binding attached to it. In the special case of null we cannot detect that String type at compile time, so we could derive it from the left-hand-side at runtime.

But if we had a string value, e.g. "A", it wouldn't be possible to be sure of whether that value is already the bind value, or the user defined type in case there's a Converter<String, String>. This problem is specific to using row() with values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant