Open levilansing opened 5 days ago
@levilansing Thanks very much for bringing this use case to our attention.
exec()
arguments have been typically tried and tested using stand-alone/throw-away columnType
s via manually-defined lists of pairs. The logic will need to be refactored if Exposed is also being used for SQL-string statement generation, with actually existing column objects being used to provide the arguments. I'll look into making this use case work as well.
Also, if you wouldn't mind sharing, is there a specific reason that insertIgnore()
does not suffice for your use case?
Feel free to tell me I'm doing it wrong, but when I try to use exposed to generate prepared statements that I execute directly on the transaction, it changes all the column types that I inserted to be nullable for all future inserts. My use case is that I want to support inserts that ignore conflicts, here's a contrived example:
Notice the generated SQL for
statement1
andstatement3
. Instatement1
, exposed knows the id column has a default value in the DB and leaves it out of the insert statement, but instatement3
(and all future insert statements), it will try to insert null because the column type has been modified permanently in the execution of statement2.This is highly problematic for any column that uses a DB generated default, as all future inserts will try to insert NULL.
I think I've tracked it down to this recent change:
https://github.com/JetBrains/Exposed/blob/3fafec1a31f88b1ea4fda13fdf17c6dc182e5693/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Transaction.kt#L253-L257