the extension compiles and runs on Python 2.4.
[ticket:2023]
+- postgresql
+ - When explicit sequence execution derives the name
+ of the auto-generated sequence of a SERIAL column,
+ which currently only occurs if implicit_returning=False,
+ now accommodates if the table + column name is greater
+ than 63 characters using the same logic Postgresql uses.
+ [ticket:1083]
+
0.6.6
=====
- orm
# execute the sequence associated with a SERIAL primary
# key column. for non-primary-key SERIAL, the ID just
# generates server side.
- sch = column.table.schema
+ try:
+ seq_name = column._postgresql_seq_name
+ except AttributeError:
+ tab = column.table.name
+ col = column.name
+ tab = tab[0:29 + max(0, (29 - len(col)))]
+ col = col[0:29 + max(0, (29 - len(tab)))]
+ column._postgresql_seq_name = seq_name = "%s_%s_seq" % (tab, col)
+
+ sch = column.table.schema
if sch is not None:
- exc = "select nextval('\"%s\".\"%s_%s_seq\"')" % \
- (sch, column.table.name, column.name)
+ exc = "select nextval('\"%s\".\"%s\"')" % \
+ (sch, seq_name)
else:
- exc = "select nextval('\"%s_%s_seq\"')" % \
- (column.table.name, column.name)
+ exc = "select nextval('\"%s\"')" % \
+ (seq_name, )
return self._execute_scalar(exc)
class SequenceTest(TestBase, AssertsCompiledSQL):
- def test_basic(self):
+ def test_format(self):
seq = Sequence('my_seq_no_schema')
dialect = postgresql.PGDialect()
assert dialect.identifier_preparer.format_sequence(seq) \
assert dialect.identifier_preparer.format_sequence(seq) \
== '"Some_Schema"."My_Seq"'
+ @testing.only_on('postgresql', 'foo')
+ @testing.provide_metadata
+ def test_reverse_eng_name(self):
+ engine = engines.testing_engine(options=dict(implicit_returning=False))
+ for tname, cname in [
+ ('tb1' * 30, 'abc'),
+ ('tb2', 'abc' * 30),
+ ('tb3' * 30, 'abc' * 30),
+ ('tb4', 'abc'),
+ ]:
+ t = Table(tname[:57],
+ metadata,
+ Column(cname[:57], Integer, primary_key=True)
+ )
+ t.create(engine)
+ r = engine.execute(t.insert())
+ assert r.inserted_primary_key == [1]
+
class CompileTest(TestBase, AssertsCompiledSQL):
__dialect__ = postgresql.dialect()