diff --git a/sqlalchemy_iris/base.py b/sqlalchemy_iris/base.py index 96bdf5f..eebfce9 100644 --- a/sqlalchemy_iris/base.py +++ b/sqlalchemy_iris/base.py @@ -468,7 +468,9 @@ def get_column_specification(self, column, **kwargs): column.primary_key and column is column.table._autoincrement_column ): - colspec.append("SERIAL") + # colspec.append("SERIAL") + # IDENTITY and ALLOWIDENTITYINSERT = 1 in table instead of SERIAL to solve issue with LAST_IDENTITY() + colspec.append("IDENTITY") else: colspec.append( self.dialect.type_compiler.process( @@ -494,6 +496,9 @@ def get_column_specification(self, column, **kwargs): return " ".join(colspec) + def post_create_table(self, table): + return " WITH %%CLASSPARAMETER ALLOWIDENTITYINSERT = 1" + class IRISTypeCompiler(compiler.GenericTypeCompiler): def visit_boolean(self, type_, **kw):