columns.append(expr)
self.expressions = expressions
+ self.name = quoted_name(name, kw.pop("quote", None))
+ self.unique = kw.pop('unique', False)
+ self.kwargs = kw
# will call _set_parent() if table-bound column
# objects are present
ColumnCollectionMixin.__init__(self, *columns)
- self.name = quoted_name(name, kw.pop("quote", None))
- self.unique = kw.pop('unique', False)
- self.kwargs = kw
+
def _set_parent(self, table):
ColumnCollectionMixin._set_parent(self, table)
parent.__class__.__name__))
def after_attach(obj, parent):
+ assert hasattr(obj, 'name') # so we can change it
canary.append("%s->%s" % (target.__name__, parent))
event.listen(target, "before_parent_attach", before_attach)
event.listen(target, "after_parent_attach", after_attach)
for target in [
schema.ForeignKeyConstraint, schema.PrimaryKeyConstraint,
schema.UniqueConstraint,
- schema.CheckConstraint
+ schema.CheckConstraint,
+ schema.Index
]:
evt(target)
m = MetaData()
Table('t1', m,
Column('id', Integer, Sequence('foo_id'), primary_key=True),
- Column('bar', String, ForeignKey('t2.id')),
+ Column('bar', String, ForeignKey('t2.id'), index=True),
Column('bat', Integer, unique=True),
)
Table('t2', m,
Column('bar', Integer),
Column('bat', Integer),
CheckConstraint("bar>5"),
- UniqueConstraint('bar', 'bat')
+ UniqueConstraint('bar', 'bat'),
+ Index(None, 'bar', 'bat')
)
eq_(
canary,
[
'PrimaryKeyConstraint->Table', 'PrimaryKeyConstraint->t1',
+ 'Index->Table', 'Index->t1',
'ForeignKeyConstraint->Table', 'ForeignKeyConstraint->t1',
'UniqueConstraint->Table', 'UniqueConstraint->t1',
'PrimaryKeyConstraint->Table', 'PrimaryKeyConstraint->t2',
'CheckConstraint->Table', 'CheckConstraint->t2',
- 'UniqueConstraint->Table', 'UniqueConstraint->t2'
+ 'UniqueConstraint->Table', 'UniqueConstraint->t2',
+ 'Index->Table', 'Index->t2'
]
)