Description
Hi, Im trying to do the following
val rowsUpdated = databaseClient.execute(
"""
UPDATE listings
SET issuer_id = :issuerId,
title = :title,
description = :description,
tags = :tags
WHERE id = :id
"""
).bind("issuerId", listing.issuerId)
.bind("title", listing.title)
.bind("description", listing.description)
.bind("tags", listing.tags)
.bind("id", listing.id!!)
.fetch()
.awaitRowsUpdated()
where tags is declared in the database as type text[]
when I run I get the following
Oct. 06, 2020 17:51:07 +1100 [Test worker @coroutine#1] DEBUG o.s.d.r.core.NamedParameterExpander: Expanding SQL statement [
UPDATE listings
SET issuer_id = :issuerId,
title = :title,
description = :description,
tags = :tags
WHERE id = :id
] to [
UPDATE listings
SET issuer_id = $1,
title = $2,
description = $3,
tags = $4, $5
WHERE id = $6
]
Oct. 06, 2020 17:51:07 +1100 [tc-okhttp-stream-370411758] ERROR c.a.a.u.postgres.DatabaseContainer: 2020-10-06 06:51:07.294 UTC [70] ERROR: syntax error at or near "$5" at character 446
I think the following is because substituteNamedParameters
in NamedParameterUtils
where there is a condition that checks if (value instanceof Collection)
and this creates separate markers for each item in the list. The case mentioned in the docs mentions queries such as select id, name, state from table where (name, age) in (('John', 35), ('Ann', 50))}
where you do want each item to be a different parameter but for my case I want it to be treated as one array type, is this supported at the moment?
When I try to pass it as a string in the format of arrays {new,here}
the error returned instead is
ERROR: column "tags" is of type text[] but expression is of type character varying at character 441
is there a workaround?
Thanks