I'm seeing the same problem with postgresql and SA 0.2. Currently
indexes are getting named like "ux_column/ix_column" - is there any
reason this couldn't be changed to "ux_table_column"?
I've made the change to schema.py and it works for me. Attached diff is
for the 0.2 branch.
Sean Cazzell
On Mon, 2006-05-15 at 21:32 +1000, Jamie Wilkinson wrote:
> The following code doesn't work when sqlite is used as a backend; the unique
> index on both tables is created with the same name.
>
> This is SQLAlchemy 0.1.7 with pysqlite2 2.2.2.
>
>
> from sqlalchemy import *
>
> a = Table('a',
> Column('id', Integer, primary_key=True),
> Column('name', String, unique=True)
> )
>
> b = Table('b',
> Column('id', Integer, primary_key=True),
> Column('name', String, unique=True)
> )
>
> global_connect('sqlite', {'filename': ':memory:'})
>
> a.create()
> b.create()
>
>
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
> _______________________________________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Index: lib/sqlalchemy/schema.py
===================================================================
--- lib/sqlalchemy/schema.py (revision 1488)
+++ lib/sqlalchemy/schema.py (working copy)
@@ -191,12 +191,12 @@
raise ValueError("index and unique may not both be specified")
if index:
if index is True:
- name = 'ix_%s' % column.name
+ name = 'ix_%s_%s' % (self.name, column.name)
else:
name = index
elif unique:
if unique is True:
- name = 'ux_%s' % column.name
+ name = 'ux_%s_%s' % (self.name, column.name)
else:
name = unique
# find this index in self.indexes