preparer = compiler.IdentifierPreparer
supports_alter = True
+ # the first value we'd get for an autoincrement
+ # column.
+ default_sequence_base = 1
+
# most DBAPIs happy with this for execute().
# not cx_oracle.
execute_sequence_format = tuple
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)] + \
row = conn.execute(table.select()).first()
eq_(
row,
- (1, "some data")
+ (config.db.dialect.default_sequence_base, "some data")
)
def test_autoincrement_on_insert(self):
row = conn.execute(table.select()).first()
eq_(
row,
- (1, "some data")
+ (config.db.dialect.default_sequence_base, "some data")
)
@classmethod