summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES10
-rw-r--r--lib/sqlalchemy/dialects/firebird/base.py3
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py1
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py1
-rw-r--r--test/sql/test_defaults.py5
5 files changed, 14 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 788fff57e..2670b4dea 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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,