From d3c73ad8012e15bf47529b3fcb0bac1298fbdb90 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Wed, 21 Apr 2021 22:49:09 +0200 Subject: Propertly ignore ``Identity`` in MySQL and MariaDb. Ensure that the MySQL and MariaDB dialect ignore the :class:`_sql.Identity` construct while rendering the ``AUTO_INCREMENT`` keyword in a create table. The Oracle and PostgreSQL compiler was updated to not render :class:`_sql.Identity` if the database version does not support it (Oracle < 12 and PostgreSQL < 10). Previously it was rendered regardless of the database version. Fixes: #6338 Change-Id: I2ca0902fdd7b4be4fc1a563cf5585504cbea9360 --- lib/sqlalchemy/sql/compiler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 6168248ff..bd93f5199 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -4257,10 +4257,15 @@ class DDLCompiler(Compiled): if column.computed is not None: colspec += " " + self.process(column.computed) - if column.identity is not None: + if ( + column.identity is not None + and self.dialect.supports_identity_columns + ): colspec += " " + self.process(column.identity) - if not column.nullable and not column.identity: + if not column.nullable and ( + not column.identity or not self.dialect.supports_identity_columns + ): colspec += " NOT NULL" return colspec -- cgit v1.2.1