summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite/test_reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-02-06 19:06:09 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-02-06 19:06:09 -0500
commita0ef9edc1908adb823ec788eee1974900bca4bac (patch)
tree276bfa6934e56b8d33fae4b287368404725506d9 /lib/sqlalchemy/testing/suite/test_reflection.py
parent47858b85ec7139af83c2cd0aed1af8917d88ea3e (diff)
downloadsqlalchemy-a0ef9edc1908adb823ec788eee1974900bca4bac.tar.gz
- adding in requirements
- get test_naturalpks to be more generalized
Diffstat (limited to 'lib/sqlalchemy/testing/suite/test_reflection.py')
-rw-r--r--lib/sqlalchemy/testing/suite/test_reflection.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py
index 89e233295..5beed6aad 100644
--- a/lib/sqlalchemy/testing/suite/test_reflection.py
+++ b/lib/sqlalchemy/testing/suite/test_reflection.py
@@ -218,6 +218,9 @@ class ComponentReflectionTest(fixtures.TablesTest):
])) > 0, '%s(%s), %s(%s)' % (col.name,
col.type, cols[i]['name'], ctype))
+ if not col.primary_key:
+ assert cols[i]['default'] is None
+
@testing.requires.table_reflection
def test_get_columns(self):
self._test_get_columns()
@@ -386,5 +389,32 @@ class ComponentReflectionTest(fixtures.TablesTest):
def test_get_table_oid_with_schema(self):
self._test_get_table_oid('users', schema='test_schema')
+ @testing.provide_metadata
+ def test_autoincrement_col(self):
+ """test that 'autoincrement' is reflected according to sqla's policy.
+
+ Don't mark this test as unsupported for any backend !
+
+ (technically it fails with MySQL InnoDB since "id" comes before "id2")
+
+ A backend is better off not returning "autoincrement" at all,
+ instead of potentially returning "False" for an auto-incrementing
+ primary key column.
+
+ """
+
+ meta = self.metadata
+ insp = inspect(meta.bind)
+
+ for tname, cname in [
+ ('users', 'user_id'),
+ ('email_addresses', 'address_id'),
+ ('dingalings', 'dingaling_id'),
+ ]:
+ cols = insp.get_columns(tname)
+ id_ = dict((c['name'], c) for c in cols)[cname]
+ assert id_.get('autoincrement', True)
+
+
__all__ = ('ComponentReflectionTest', 'HasTableTest')