quote=self.quote,
index=self.index,
autoincrement=self.autoincrement,
+ default=self.default,
+ server_default=self.server_default,
+ onupdate=self.onupdate,
+ server_onupdate=self.server_onupdate,
*[c.copy(**kw) for c in self.constraints])
def _make_proxy(self, selectable, name=None):
eq_(c.type.length, reflected_c.type.length)
eq_(set([f.column.name for f in c.foreign_keys]), set([f.column.name for f in reflected_c.foreign_keys]))
- if c.default:
+ if c.server_default:
assert isinstance(reflected_c.server_default,
schema.FetchedValue)
- elif against(('mysql', '<', (5, 0))):
- # ignore reflection of bogus db-generated DefaultClause()
- pass
- elif not c.primary_key or not against('postgresql', 'mssql'):
- #print repr(c)
- assert reflected_c.default is None, reflected_c.default
assert len(table.primary_key) == len(reflected_table.primary_key)
for c in table.primary_key:
table = Table('mytable', meta,
Column('myid', Integer, primary_key=True),
Column('name', String(40), nullable=True),
+ Column('foo', String(40), nullable=False, server_default='x', server_onupdate='q'),
+ Column('bar', String(40), nullable=False, default='y', onupdate='z'),
Column('description', String(30), CheckConstraint("description='hi'")),
UniqueConstraint('name'),
test_needs_fk=True,
meta.create_all(testing.db)
try:
- for test, has_constraints in ((test_to_metadata, True), (test_pickle, True),(test_pickle_via_reflect, False)):
+ for test, has_constraints, reflect in ((test_to_metadata, True, False), (test_pickle, True, False),(test_pickle_via_reflect, False, True)):
table_c, table2_c = test()
self.assert_tables_equal(table, table_c)
self.assert_tables_equal(table2, table2_c)
assert table.primary_key is not table_c.primary_key
assert list(table2_c.c.myid.foreign_keys)[0].column is table_c.c.myid
assert list(table2_c.c.myid.foreign_keys)[0].column is not table.c.myid
-
+ assert str(table_c.c.foo.server_default.arg) == 'x'
+
+ if not reflect:
+ assert str(table_c.c.foo.server_onupdate.arg) == 'q'
+ assert str(table_c.c.bar.default.arg) == 'y'
+ assert getattr(table_c.c.bar.onupdate.arg, 'arg', table_c.c.bar.onupdate.arg) == 'z'
+
# constraints dont get reflected for any dialect right now
if has_constraints:
for c in table_c.c.description.constraints: