]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
anonymous indexes use column._label to avoid name collisions
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 May 2006 14:59:32 +0000 (14:59 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 May 2006 14:59:32 +0000 (14:59 +0000)
CHANGES
lib/sqlalchemy/schema.py
test/indexes.py

diff --git a/CHANGES b/CHANGES
index cc6e7fe32eecd5cdbbdd9d9ce3c797715f49f0e3..f5f715881cdf0f6dbb04e5cd62d4ebb6c0a057d0 100644 (file)
--- 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..])
index 3fc3752c7bf310af37b0b85761a5e79d9434a712..c8824901144962c764bce8109076fd327d2fd338 100644 (file)
@@ -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
index 7ad008f5dca9a28197cd7e1baf3c7bbcfbf93c4f..fbf1a2c81c1a2bc907c558d0609f0e5c5530e5f1 100644 (file)
@@ -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() == \