I have following problem with batch insert:
dslContext.batch(
dslContext.insertInto(
TABLE,
FIELD_1,
FIELD_2,
FIELD_3,
FIELD_4_TS_VECTOR
).values(0L, "", "", "")
.onConflictDoNothing()
).bind(value1, value2, value3, value4.toTsvector())
.execute()
Where toTsvector is:
private fun String.toTsvector() =
DSL.field("to_tsvector('simple', {0})", this)
In this case it seems DSL.field is not working as expected because instead of binding it just returns value and execution of this query fails with:
org.jooq.exception.DataAccessException: SQL [insert into "table" ("field_1", "field_2", "field_3", "field_4_ts_vector") values (?, ?, ?, ?) on conflict do nothing]; Batch entry 0 insert into "table" ("field_1", "field_2", "field_3", "field_4_ts_vector") values (100500, 'value2', 'value3', 'value4') on conflict do nothing was aborted: ERROR: column "field_4_ts_vector" is of type tsvector but expression is of type character varying
But if 'usual' insert is used everything works fine:
dslContext.insertInto(
TABLE,
FIELD_1,
FIELD_2,
FIELD_3,
FIELD_4_TS_VECTOR
).values(value1, value2, value3, value4.toTsvector())
.onConflictDoNothing()
.execute()
Thanks!