diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-23 14:59:32 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-05-23 14:59:32 +0000 |
commit | 5156d5141af04fe86ba317eadb73d8442eddc651 (patch) | |
tree | 7284c66acd79e1cef9fcce50d149266a63c54882 | |
parent | 1bbee677746e344336667bf97fd16d3df8af0c89 (diff) | |
download | sqlalchemy-5156d5141af04fe86ba317eadb73d8442eddc651.tar.gz |
anonymous indexes use column._label to avoid name collisions
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/schema.py | 4 | ||||
-rw-r--r-- | test/indexes.py | 8 |
3 files changed, 9 insertions, 6 deletions
@@ -1,3 +1,6 @@ +next +- anonymous indexes (via Column(unique=True) etc) use column._label for naming +to avoid collisions 0.1.7 - some fixes to topological sort algorithm - added DISTINCT ON support to Postgres (just supply distinct=[col1,col2..]) diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 3fc3752c7..c88249011 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -208,12 +208,12 @@ class Table(sql.TableClause, SchemaItem): raise ValueError("index and unique may not both be specified") if index: if index is True: - name = 'ix_%s' % column.name + name = 'ix_%s' % column._label else: name = index elif unique: if unique is True: - name = 'ux_%s' % column.name + name = 'ux_%s' % column._label else: name = unique # find this index in self.indexes diff --git a/test/indexes.py b/test/indexes.py index 7ad008f5d..fbf1a2c81 100644 --- a/test/indexes.py +++ b/test/indexes.py @@ -87,8 +87,8 @@ class IndexTest(testbase.AssertMixin): Column('winner', String(30), index='idx_winners')) index_names = [ ix.name for ix in events.indexes ] - assert 'ux_name' in index_names - assert 'ix_location' in index_names + assert 'ux_events_name' in index_names + assert 'ix_events_location' in index_names assert 'sport_announcer' in index_names assert 'idx_winners' in index_names assert len(index_names) == 4 @@ -104,9 +104,9 @@ class IndexTest(testbase.AssertMixin): assert capt[0].strip().startswith('CREATE TABLE events') assert capt[2].strip() == \ - 'CREATE UNIQUE INDEX ux_name ON events (name)' + 'CREATE UNIQUE INDEX ux_events_name ON events (name)' assert capt[4].strip() == \ - 'CREATE INDEX ix_location ON events (location)' + 'CREATE INDEX ix_events_location ON events (location)' assert capt[6].strip() == \ 'CREATE UNIQUE INDEX sport_announcer ON events (sport, announcer)' assert capt[8].strip() == \ |