-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Transaction.exec changes all referenced columns to be nullable going forward #2142
Comments
@levilansing Thanks very much for bringing this use case to our attention.
Also, if you wouldn't mind sharing, is there a specific reason that |
Thanks for looking into this @bog-walk. I'm trying to build responsibly and want to limit manual SQL as much as possible when I need something custom. I personally feel the best balance is to augment exposed generated SQL so I get the safety of exposed using my data model exactly as it is defined in one place with some flexibility to create more optimal queries for my needs. I understand now that may be contrary to the intent of For my actual use cases right now (w/postgres), a batch insert ignore, and a handful of update statements that return specific columns including DB generated values. I was on v 0.48, but after doing some more research now I see |
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:
Exposed/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Transaction.kt
Lines 253 to 257 in 3fafec1
The text was updated successfully, but these errors were encountered: