self._init_items(*args)
def _autoload(self, metadata, autoload_with, include_columns):
+ if self.primary_key.columns:
+ PrimaryKeyConstraint()._set_parent_with_dispatch(self)
+
if autoload_with:
autoload_with.run_callable(
autoload_with.dialect.reflecttable,
meta = self.metadata
t1 = Table('t', meta,
+ Column('id', Integer, primary_key=True),
Column('x', Integer),
Column('y', Integer),
Column('z', Integer, server_default="5"),
meta.create_all()
m2 = MetaData()
- old_z = Column('z', String)
+ old_z = Column('z', String, primary_key=True)
old_y = Column('y', String)
old_q = Column('q', Integer)
t2 = Table('t', m2, old_z, old_q)
+ eq_(t2.primary_key.columns, (t2.c.z, ))
t2 = Table('t', m2, old_y,
extend_existing=True,
autoload=True,
autoload_with=testing.db)
eq_(
set(t2.columns.keys()),
- set(['x', 'y', 'z', 'q'])
+ set(['x', 'y', 'z', 'q', 'id'])
)
+ eq_(t2.primary_key.columns, (t2.c.id, ))
assert t2.c.z is not old_z
assert t2.c.y is old_y
assert t2.c.z.type._type_affinity is Integer