summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-03-24 14:31:48 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-03-24 14:31:48 -0400
commit5e66224d63cf1f23fce8a7fde83e791ca475f099 (patch)
tree9040121d35828f03993926c413a7573e18b9918b /lib/sqlalchemy/testing/schema.py
parenta4703917d82a7100ff91d938c0592e39dd757a64 (diff)
downloadsqlalchemy-5e66224d63cf1f23fce8a7fde83e791ca475f099.tar.gz
- add an event to testing so that other dialects can intercept "test_needs_autoincrement"
- get the assumption of "1" for "first sequence item" to be dialect configured
Diffstat (limited to 'lib/sqlalchemy/testing/schema.py')
-rw-r--r--lib/sqlalchemy/testing/schema.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/sqlalchemy/testing/schema.py b/lib/sqlalchemy/testing/schema.py
index ad233ec22..325d74f1e 100644
--- a/lib/sqlalchemy/testing/schema.py
+++ b/lib/sqlalchemy/testing/schema.py
@@ -66,18 +66,27 @@ def Column(*args, **kw):
col = schema.Column(*args, **kw)
if 'test_needs_autoincrement' in test_opts and \
- kw.get('primary_key', False) and \
- exclusions.against('firebird', 'oracle'):
- def add_seq(c, tbl):
- c._init_items(
- schema.Sequence(_truncate_name(
- config.db.dialect, tbl.name + '_' + c.name + '_seq'),
- optional=True)
- )
- event.listen(col, 'after_parent_attach', add_seq, propagate=True)
+ kw.get('primary_key', False):
+
+ # allow any test suite to pick up on this
+ col.info['test_needs_autoincrement'] = True
+
+ # hardcoded rule for firebird, oracle; this should
+ # be moved out
+ if exclusions.against('firebird', 'oracle'):
+ def add_seq(c, tbl):
+ c._init_items(
+ schema.Sequence(_truncate_name(
+ config.db.dialect, tbl.name + '_' + c.name + '_seq'),
+ optional=True)
+ )
+ event.listen(col, 'after_parent_attach', add_seq, propagate=True)
return col
+
+
+
def _truncate_name(dialect, name):
if len(name) > dialect.max_identifier_length:
return name[0:max(dialect.max_identifier_length - 6, 0)] + \