summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-05-23 14:59:32 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-05-23 14:59:32 +0000
commit5156d5141af04fe86ba317eadb73d8442eddc651 (patch)
tree7284c66acd79e1cef9fcce50d149266a63c54882
parent1bbee677746e344336667bf97fd16d3df8af0c89 (diff)
downloadsqlalchemy-5156d5141af04fe86ba317eadb73d8442eddc651.tar.gz
anonymous indexes use column._label to avoid name collisions
-rw-r--r--CHANGES3
-rw-r--r--lib/sqlalchemy/schema.py4
-rw-r--r--test/indexes.py8
3 files changed, 9 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index cc6e7fe32..f5f715881 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 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() == \