I have created a type as below:
CREATE TYPE schema.custom_type AS (
name VARCHAR(255),
lastname VARCHAR(255),
is_old BOOLEAN,
propagate BOOLEAN);
And I have a table that has an array of custom_type as shown below:
CREATE TABLE IF NOT EXISTS schema.entity (
entity_id VARCHAR(255),
temp_id VARCHAR(255),
associations schema.custom_type[],
PRIMARY KEY (entity_id, temp_id)
);
Now I have a requirement to execute the below query in jooq:
update schema.entity SET associations = array_remove(associations, ('name1','lastname1',true,true)::associations) where entity_id = '85f74dc4-ab9f-46b5-8fce-1591b9b24b03';
I tried below but its giving me complier error to cast arguments to RowN and if I do that then at runtime I get error saying that there is no data type custom_type in postgres.
Field<CustomTypeRecord> f = DSL.val(new CustomTypeRecord("name1", "lastname1",true, true));
dslContext.update(Tables.ENTITY)
.set( Tables.ENTITY.ASSOCIATIONS, DSL.field("array_remove({0}, {1})", f.getDataType(), Tables.ENTITY.ASSOCIATIONS, f))
.where(Tables.ENTITY.ENTITY_ID.eq("85f74dc4-ab9f-46b5-8fce-1591b9b24b03")
.execute();
Can you please help me construct this.