The original issue is that upsert() creates incorrect value in the database for Json column and H2 database.
As I understood the root of the problem is that jdbc driver works differently for insert and merge prepared statements. In the case of insert the json string is saved in the db as it is, in the merge case it is stored with escaping characters...
With this PR the new method in IColumnType is introduced: fun parameterMarker(value: T?) = "?"
It allows for the JsonColumnType to specify modifier for the parameter marker inside a prepared statement (so it looks like ? FORMAT JSON).
It's done on the column type, because another db-specific check is made on this level also (like in valueFromDB/valueToDB), and it would also allow to make similar customizations for other columns (CAST in MySql, cast via ::<type> in Postgres, probably named/ordered parameters, but it's more complicated because more information is needed) if it's necessary.
The original issue is that
upsert()
creates incorrect value in the database for Json column and H2 database.As I understood the root of the problem is that jdbc driver works differently for
insert
andmerge
prepared statements. In the case ofinsert
the json string is saved in the db as it is, in themerge
case it is stored with escaping characters...Some more details on YouTrack/EXPOSED-393
With this PR the new method in
IColumnType
is introduced:fun parameterMarker(value: T?) = "?"
It allows for the
JsonColumnType
to specify modifier for the parameter marker inside a prepared statement (so it looks like? FORMAT JSON
).It's done on the column type, because another db-specific check is made on this level also (like in
valueFromDB
/valueToDB
), and it would also allow to make similar customizations for other columns (CAST
in MySql, cast via::<type>
in Postgres, probably named/ordered parameters, but it's more complicated because more information is needed) if it's necessary.