qizhiyi / sqlalchemy-migrate

Automatically exported from code.google.com/p/sqlalchemy-migrate
MIT License
0 stars 0 forks source link

ForeignKeyConstraint constraint name is doublequoted #142

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to drop a foreign key using ForeignKeyConstraint like this:

def upgrade(migrate_engine):
    contactCaches = Table("contactCaches", meta, autoload=True)
    #...
    oldFk = ForeignKeyConstraint([contactCaches.c.contactId], [contacts.c.id], name="contactCaches_contactId_fkey")
    oldFk.drop()

It doesn't matter if the name kwarg is given or not, the result is the same.

What is the expected output? What do you see instead?

This is the generated query including the raised exception:
 (ProgrammingError) constraint ""contactCaches_contactId_fkey"" of relation "contactCaches" does not exist
 'ALTER TABLE "contactCaches" DROP CONSTRAINT """contactCaches_contactId_fkey"""'

Expected and working query:
 'ALTER TABLE "contactCaches" DROP CONSTRAINT "contactCaches_contactId_fkey"'

What version of the product are you using? On what operating system?
sqlalchemy-migrate 0.7.2 
sqlalchemy 0.7.4
python 2.7
postgresql 9.0.4 

The problem is fixed by skipping the quoting in 
migrate/changeset/ansisql.py:ANSIConstraintCommon.get_constraint_name.
I don't know if this breaks other things, it didn't for me.

Original issue reported on code.google.com by bas...@gmail.com on 24 Jan 2012 at 4:24