From: Mike Bayer Date: Tue, 23 May 2006 14:59:32 +0000 (+0000) Subject: anonymous indexes use column._label to avoid name collisions X-Git-Tag: rel_0_2_0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5156d5141af04fe86ba317eadb73d8442eddc651;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git anonymous indexes use column._label to avoid name collisions --- diff --git a/CHANGES b/CHANGES index cc6e7fe32e..f5f715881c 100644 --- a/CHANGES +++ b/CHANGES @@ -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 3fc3752c7b..c882490114 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 7ad008f5dc..fbf1a2c81c 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() == \