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

Cannot insert varchar[] column value using jooq #16671

Open
srijan-96 opened this issue May 12, 2024 · 2 comments
Open

Cannot insert varchar[] column value using jooq #16671

srijan-96 opened this issue May 12, 2024 · 2 comments

Comments

@srijan-96
Copy link

srijan-96 commented May 12, 2024

Actual behavior

DB Schema
CREATE TABLE sanctions.sanction_suspension
(
id bigserial not null,
sanction_id varchar(255) NOT NULL,
suspension_status int NOT NULL,
created_on timestamp not null default now(),
last_updated_on timestamp not null default now(),
suspension_reasons varchar[],
CONSTRAINT sanction_id_unique UNIQUE (sanction_id),
CONSTRAINT sanction_suspension_pk PRIMARY KEY (id)
);

jooq Generated Column

public final TableField<SanctionSuspensionRecord, String[]> SUSPENSION_REASONS = createField("suspension_reasons", org.jooq.impl.SQLDataType.VARCHAR.getArrayDataType(), this, "");

Code to insert values into table

DSL.using(config).insertInto(SANCTION_SUSPENSION).
			set(SANCTION_SUSPENSION.SUSPENSION_REASONS, new String[]{"30", "40"}).execute();
	}

Error:
org.jooq.exception.DataAccessException: SQL [insert into "sanctions"."sanction_suspension" ("created_on", "sanction_id", "suspension_reasons", "suspension_status", "last_updated_on") values (cast(? as timestamp), ?, ?::varchar[], ?, cast(? as timestamp))]; [Amazon]JDSI Data type not supported: 1111] with root cause

Expected behavior

Should insert the value

Steps to reproduce the problem

Create a postgres table with varchar[] column
Run jooq code generation Tool (mvn clean package -DskipTests -Pjooq)
Run maven Application
Use DSL to insert data into the column

jOOQ Version

3.10.4

Database product and version

Postgres 9.4.1212

Java Version

8

JDBC / R2DBC driver name and version (include name if unofficial driver)

org.postgresq:postgresq:9.4.1212

@srijan-96
Copy link
Author

Tried Using DSL.val(array, SQLDataType.VARCHAR.getArrayDataType())

Same error

@lukaseder
Copy link
Member

Thanks for your message. I'm not aware of any such limitation, though all of the versions you've shown are very dated. You probably have your reasons for sticking to outdated libraries...

But to help you, I'll have to see at least:

  • The complete stack trace
  • A complete reproducer (that ensures all the outdated stuff is linked properly, it's impossible to find your specific configuration by trial and error on my side). We have a template for Minimal, Complete, Verifiable Examples here to help reproducing such issues: https://github.com/jOOQ/jOOQ-mcve

The main hint I'm seeing is "Data type not supported: 1111", where 1111 corresponds to java.sql.Types.OTHER, clearly something that jOOQ normally doesn't use when binding arrays to pgjdbc.

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

2 participants