-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Expected behavior
The query contains the correct type information and executes successfully
Actual behavior
Query loses the types and PG fails to derive it, so the query fails to execute
Steps to reproduce the problem
Create a test table, something like this:
create table sales
(
id int primary key not null,
name text not null,
price int not null,
tenant_id uuid NOT NULL
);
Define a tenant:
val tenantA = UUID.fromString("55be0301-83f5-45e6-8e1d-e902fe99dc43")Add jOOQ policies on the table:
DefaultPolicyProvider().append(SALES, SALES.TENANT_ID.eq(tenantA))Run the query that uses .batch, like:
context.batch(
context
.insertInto(Sales.SALES)
.set(SalesRecord()
.also {
it.id = 100
it.name = "test"
it.price = 1
it.tenantId = tenantA
})
).execute()it would generate and run the following query:
INSERT INTO
"public"."sales" ("id", "name", "price", "tenant_id")
SELECT
"t"."id",
"t"."name",
"t"."price",
"t"."tenant_id"
FROM
(
SELECT
100,
'test',
1,
'55be0301-83f5-45e6-8e1d-e902fe99dc43'
) AS "t" ("id", "name", "price", "tenant_id")
WHERE
"t"."tenant_id" = '55be0301-83f5-45e6-8e1d-e902fe99dc43';that fails with the following error:
Caused by: org.postgresql.util.PSQLException: ERROR: column "tenant_id" is of type uuid but expression is of type text
Hint: You will need to rewrite or cast the expression.
jOOQ Version
3.19.4
Database product and version
PostgreSQL 15.2
Java Version
Amazon Corretto 17
OS Version
MacOS 14.2.1
JDBC driver name and version (include name if unofficial driver)
No response
feser and mmirboboev