diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-01-15 16:50:52 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-01-15 16:50:52 -0500 |
commit | aedd34f34f083019918fc30c280fbe8ad57eeecf (patch) | |
tree | 1e3dc0b810f179e38982064e4955a8b6c8b01aca | |
parent | dff5a404e489d5215da5aa30870b78aca8423de5 (diff) | |
download | sqlalchemy-aedd34f34f083019918fc30c280fbe8ad57eeecf.tar.gz |
Regarding reflection for this case, reflection of an int PK col
with a server_default sets the "autoincrement" flag to False,
except in the case of a PG SERIAL col where we detected a
sequence default. [ticket:2020] [ticket:2021]
-rw-r--r-- | CHANGES | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/firebird/base.py | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/oracle/base.py | 1 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/sqlite/base.py | 1 | ||||
-rw-r--r-- | test/sql/test_defaults.py | 5 |
5 files changed, 14 insertions, 6 deletions
@@ -25,6 +25,16 @@ CHANGES the underlying database type as being Integer-based. [ticket:2005] + - Established consistency when server_default is present + on an Integer PK column. SQLA doesn't pre-fetch these, + nor do they come back in cursor.lastrowid (DBAPI). + Ensured all backends consistently return None + in result.inserted_primary_key for these. Regarding + reflection for this case, reflection of an int PK col + with a server_default sets the "autoincrement" flag to False, + except in the case of a PG SERIAL col where we detected a + sequence default. [ticket:2020] [ticket:2021] + - Result-row processors are applied to pre-executed SQL defaults, as well as cursor.lastrowid, when determining the contents of result.inserted_primary_key. diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py index feca46bce..32ffbfd69 100644 --- a/lib/sqlalchemy/dialects/firebird/base.py +++ b/lib/sqlalchemy/dialects/firebird/base.py @@ -586,7 +586,8 @@ class FBDialect(default.DefaultDialect): 'name' : name, 'type' : coltype, 'nullable' : not bool(row['null_flag']), - 'default' : defvalue + 'default' : defvalue, + 'autoincrement':default is None } if orig_colname.lower() == orig_colname: diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 63ad37ce9..8065861c1 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -857,6 +857,7 @@ class OracleDialect(default.DefaultDialect): 'type': coltype, 'nullable': nullable, 'default': default, + 'autoincrement':default is None } if orig_colname.lower() == orig_colname: cdict['quote'] = True diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 2fadda68c..f732f1f44 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -538,6 +538,7 @@ class SQLiteDialect(default.DefaultDialect): 'type' : coltype, 'nullable' : nullable, 'default' : default, + 'autoincrement':default is None, 'primary_key': primary_key }) return columns diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index 0d099a786..1f2226842 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -836,9 +836,6 @@ class ServerDefaultsOnPKTest(testing.TestBase): t.select().execute().fetchall(), [(5, 'data')] ) - @testing.fails_on('firebird', "col comes back as autoincrement") - @testing.fails_on('sqlite', "col comes back as autoincrement") - @testing.fails_on('oracle', "col comes back as autoincrement") @testing.provide_metadata def test_autoincrement_reflected_from_server_default(self): t = Table('x', metadata, @@ -854,8 +851,6 @@ class ServerDefaultsOnPKTest(testing.TestBase): t2 = Table('x', m2, autoload=True, implicit_returning=False) assert t2._autoincrement_column is None - @testing.fails_on('firebird', "attempts to insert None") - @testing.fails_on('sqlite', "returns a value") @testing.provide_metadata def test_int_default_none_on_insert_reflected(self): t = Table('x', metadata, |