Skip to content

Commit 3ac0121

Browse files
committed
fix for incorrect lastrowid
1 parent 2622fee commit 3ac0121

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sqlalchemy_iris/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,9 @@ def get_column_specification(self, column, **kwargs):
468468
column.primary_key
469469
and column is column.table._autoincrement_column
470470
):
471-
colspec.append("SERIAL")
471+
# colspec.append("SERIAL")
472+
# IDENTITY and ALLOWIDENTITYINSERT = 1 in table instead of SERIAL to solve issue with LAST_IDENTITY()
473+
colspec.append("IDENTITY")
472474
else:
473475
colspec.append(
474476
self.dialect.type_compiler.process(
@@ -494,6 +496,9 @@ def get_column_specification(self, column, **kwargs):
494496

495497
return " ".join(colspec)
496498

499+
def post_create_table(self, table):
500+
return " WITH %%CLASSPARAMETER ALLOWIDENTITYINSERT = 1"
501+
497502

498503
class IRISTypeCompiler(compiler.GenericTypeCompiler):
499504
def visit_boolean(self, type_, **kw):

0 commit comments

Comments
 (0)