- Further reworked the "mixin" logic in declarative to
additionally allow __mapper_args__ as a @classproperty
on a mixin, such as to dynamically assign polymorphic_identity.
+
+- postgresql
+ - Postgresql now reflects sequence names associated with
+ SERIAL columns correctly, after the name of of the sequence
+ has been changed. Thanks to Kumar McMillan for the patch.
+ [ticket:1071]
- oracle
- Now using cx_oracle output converters so that the
result = connection.execute(
sql.text(u"SELECT relname FROM pg_class c "
"WHERE relkind = 'r' "
- "AND '%s' = (select nspname from pg_namespace n where n.oid = c.relnamespace) " %
+ "AND '%s' = (select nspname from pg_namespace n "
+ "where n.oid = c.relnamespace) " %
current_schema,
typemap = {'relname':sqltypes.Unicode}
)
SELECT relname
FROM pg_class c
WHERE relkind = 'v'
- AND '%(schema)s' = (select nspname from pg_namespace n where n.oid = c.relnamespace)
+ AND '%(schema)s' = (select nspname from pg_namespace n
+ where n.oid = c.relnamespace)
""" % dict(schema=current_schema)
# Py3K
#view_names = [row[0] for row in connection.execute(s)]
SQL_COLS = """
SELECT a.attname,
pg_catalog.format_type(a.atttypid, a.atttypmod),
- (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d
+ (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)
+ FROM pg_catalog.pg_attrdef d
WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef)
AS DEFAULT,
a.attnotnull, a.attnum, a.attrelid as table_oid
finally:
t.drop(checkfirst=True)
+ def test_renamed_sequence_reflection(self):
+ m1 = MetaData(testing.db)
+ t = Table('t', m1,
+ Column('id', Integer, primary_key=True)
+ )
+ m1.create_all()
+ try:
+ m2 = MetaData(testing.db)
+ t2 = Table('t', m2, autoload=True, implicit_returning=False)
+ eq_(t2.c.id.server_default.arg.text, "nextval('t_id_seq'::regclass)")
+
+ r = t2.insert().execute()
+ eq_(r.inserted_primary_key, [1])
+
+ testing.db.connect().\
+ execution_options(autocommit=True).\
+ execute("alter table t_id_seq rename to foobar_id_seq")
+
+ m3 = MetaData(testing.db)
+ t3 = Table('t', m3, autoload=True, implicit_returning=False)
+ eq_(t3.c.id.server_default.arg.text, "nextval('foobar_id_seq'::regclass)")
+
+ r = t3.insert().execute()
+ eq_(r.inserted_primary_key, [2])
+
+ finally:
+ m1.drop_all()
+
+
def test_distinct_on(self):
t = Table('mytable', MetaData(testing.db),
Column('id', Integer, primary_key=True),