diff options
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/base.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 7a04beb57..4d638ea1d 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -517,6 +517,10 @@ class ColumnCollection(util.OrderedProperties): # columns collection existing = self[key] + + if existing is value: + return + if not existing.shares_lineage(value): util.warn('Column %r on table %r being replaced by ' '%r, which has the same key. Consider ' diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 9b73eca63..7a78a715f 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -3402,7 +3402,7 @@ class Index(DialectKWArgs, ColumnCollectionMixin, SchemaItem): documented arguments. """ - self.table = None + self.table = table = None columns = [] processed_expressions = [] @@ -3417,12 +3417,21 @@ class Index(DialectKWArgs, ColumnCollectionMixin, SchemaItem): self.unique = kw.pop('unique', False) if 'info' in kw: self.info = kw.pop('info') + + # TODO: consider "table" argument being public, but for + # the purpose of the fix here, it starts as private. + if '_table' in kw: + table = kw.pop('_table') + self._validate_dialect_kwargs(kw) # will call _set_parent() if table-bound column # objects are present ColumnCollectionMixin.__init__(self, *columns) + if table is not None: + self._set_parent(table) + def _set_parent(self, table): ColumnCollectionMixin._set_parent(self, table) |
