index creation fails when table outside of 'public' schema (postgresql)
Issue #90
resolved
Attempting to create a table with a unique index fails when the table is outside of the default schema.
Executing the following code:
from sqlalchemy import *
engine = create_engine('postgres', {'database':'james'})
test_table = Table('my_table', engine,
Column('id', Integer, primary_key=True),
Column('data', String(20), unique=True, nullable=False),
schema='my_schema'
)
test_table.create()
Results in:
SQLError: (ProgrammingError) relation "my_table" does not exist
The generated SQL query looks something like:
CREATE UNIQUE INDEX ux_data ON my_table (data)
However I believe it should be
CREATE UNIQUE INDEX ux_data ON my_schema.my_table (data)
Also, I think the name 'ux_data' would collide if more than one table specified a unique index on a column named 'data'.
Comments (3)
-
Account Deleted -
repo owner - changed status to resolved
unit tests pass, table.fullname is defined as just the name if no schema is specified so should be good, committed in changeset:1105
-
repo owner - changed component to schema
- Log in to comment
I believe this problem can be fixed with the following patch, however I'm not sure if this will break anything else.