diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-20 10:26:09 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-20 10:26:09 -0500 |
commit | 65bd6ec96602ab8b755b9bc25638957a09477de6 (patch) | |
tree | e6474cea1324cf0921cc542ce38d153d86bd814c /lib/sqlalchemy/sql/compiler.py | |
parent | 5402e2f5dde680ea5715f81a2e6c3ccf7274afeb (diff) | |
download | sqlalchemy-65bd6ec96602ab8b755b9bc25638957a09477de6.tar.gz |
- Fixed issue where a primary key column that has a Sequence on it,
yet the column is not the "auto increment" column, either because
it has a foreign key constraint or ``autoincrement=False`` set,
would attempt to fire the Sequence on INSERT for backends that don't
support sequences, when presented with an INSERT missing the primary
key value. This would take place on non-sequence backends like
SQLite, MySQL. [ticket:2896]
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index bd886bd40..b09900570 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2035,7 +2035,13 @@ class SQLCompiler(Compiled): else: self.returning.append(c) else: - if c.default is not None or \ + if ( + c.default is not None and + ( + not c.default.is_sequence or + self.dialect.supports_sequences + ) + ) or \ c is stmt.table._autoincrement_column and ( self.dialect.supports_sequences or self.dialect.preexecute_autoincrement_sequences |