From 9d38ed33400adf3ba8fdf3af49f26de1270bbe23 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 11 Oct 2013 15:55:57 -0400 Subject: The "name" attribute is set on :class:`.Index` before the "attach" events are called, so that attachment events can be used to dynamically generate a name for the index based on the parent table and/or columns. [ticket:2835] --- lib/sqlalchemy/sql/schema.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 92220b0d1..c493b9132 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -2600,14 +2600,15 @@ class Index(ColumnCollectionMixin, SchemaItem): 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) -- cgit v1.2.1