Open quantranhong1999 opened 10 months ago
Thanks for your message. That's just what the r2dbc driver does out of the box:
// No jOOQ involved:
List<Object> o;
System.out.println(
o = Flux.from(cf.create())
.flatMap(c -> c.createStatement("select '\"a\"=>\"b\"'::hstore").execute())
.flatMap(it -> it.map((r, m) -> r.get(0)))
.collectList()
.block()
);
System.out.println(o.get(0).getClass());
This prints:
[{a=b}]
class java.util.LinkedHashMap
You're not actually using jOOQ's binding in your plain SQL query:
Hstore hstore = Mono.from(dslContext.select()
.from(table)
.limit(1))
.map(record -> record.get(hstoreColumn))
.block();
Think about it. How would jOOQ know your intention of binding Hstore
to this query? You're not supplying any such information to jOOQ. Now, I'm not convinced that the HstoreBinding
will work with R2DBC. From what I can tell, the pgjdbc driver works with a String encoding for the value, whereas the r2dbc driver already converted the value for you. So, you'll have to roll your own.
I keep this issue open to support Hstore
also with R2DBC in the future (but you'll still have to write a correct query that provides jOOQ with the binding!)
How would jOOQ know your intention of binding Hstore to this query? You're not supplying any such information to jOOQ.
It is true that if I put specifically hstoreColumn
in the .select
, then it would return just fine the Hstore
:
Hstore hstore = Mono.from(dslContext.select(hstoreColumn)
.from(table)
.limit(1))
.map(record -> record.get(hstoreColumn))
.block();
I expected to not need to cast hstore
during the SELECT as I created a column with the hstore
data type already (so I expected it to return the hstore
data type directly without any casting).
BTW I am new to hstore / Postgres / jOOQ so I likely mis-used the query.
Thank you for your clarification!
Expected behavior
When I record.get a Hstore column, I expect the runtime return type is the same as compilation time's return type - which is
Hstore
.Actual behavior
But the return type at runtime is
java.util.LinkedHashMap
.Steps to reproduce the problem
The build has no problem. But at runtime the test fails with the error:
jOOQ Version
jOOQ 3.16.23 and jooq-postgres-extensions 3.16.23
Database product and version
PostgreSQL 16.1
Java Version
openjdk 11
OS Version
Ubuntu 22.04
JDBC driver name and version (include name if unofficial driver)
r2dbc-postgresql 1.0.3.RELEASE