sqldelight question: is there any way for me to ru...
# squarelibraries
n
sqldelight question: is there any way for me to run something using system columns?
Copy code
RETURNING (xmax = 0) AS inserted
is a trick to determine if a row got inserted or updated (and i hope it still works) but sqldelight does not know what
xmax
is anyone got ideas on this ? from: https://stackoverflow.com/questions/39058213/differentiate-inserted-and-updated-rows-in-upsert-using-system-columns
g
Sadly - it’s not supported yet in SqlDelight PostgreSql grammar - for currently unsupported sql the escape hatch is always
driver.execute
There are two issues - these can be created in https://github.com/sqldelight/sqldelight/issues 1. Support System Columns https://www.postgresql.org/docs/current/ddl-system-columns.html in all column results 2. Add support for expressions in
RETURNING
Unless you can determine if the conflict column value is now returning a new value for the primary key (e.g generated by a sequence) or an updated column with a new timestamp the above solution seems still valid
n
well we did explore that a little bit more and it turns out it wouldn't help us anyways (works in a test table but breaks when using it on a partitioned table we did just go back to bruteforcing
ON CONFLICT DO NOTHING RETURNING id
and thenredoing the insert ... we are preprocessig data enough that it should not too much of a issue