Migrated issue, originally created by Wil Tan ()
In offline mode, Alembic emits IDENTITY INSERT mode control statements. However, in online mode, it does not do so.
There are a few shortcomings that trips up my use cases:
-
in offline mode, sometimes I bulk_insert into a table with no auto-increment key. The SET IDENTITY INSERT <table> ON statement will result in an error in MSSQL.
-
in online mode, sometimes I do want to insert fixed primary key values for auto-increment fields, but because Alembic does not turn on IDENTITY INSERT mode, MSSQL throws an error.
Would it make sense to change the current behaviour in alembic/ddl/mssql.py such that it emits SET IDENTITY INSERT statements if the rows data contains the table._autoincrement_column, regardless of offline/online mode?
I'm happy to work on a pull request if you agree with the approach.
Migrated issue, originally created by Wil Tan ()
In offline mode, Alembic emits IDENTITY INSERT mode control statements. However, in online mode, it does not do so.
There are a few shortcomings that trips up my use cases:
in offline mode, sometimes I
bulk_insertinto a table with no auto-increment key. TheSET IDENTITY INSERT <table> ONstatement will result in an error in MSSQL.in online mode, sometimes I do want to insert fixed primary key values for auto-increment fields, but because Alembic does not turn on IDENTITY INSERT mode, MSSQL throws an error.
Would it make sense to change the current behaviour in alembic/ddl/mssql.py such that it emits
SET IDENTITY INSERTstatements if the rows data contains thetable._autoincrement_column, regardless of offline/online mode?I'm happy to work on a pull request if you agree with the approach.