#230 ForeignKey gets error with column names that contain "

open
nobody
Postgres (36)
5
2013-01-18
2007-11-02
Kenji Noguchi
No

Maybe this is PostgreSQL specific problem. Postgres needs table/column names to be quoted by "" when the name is non-ASCII or when you need to preserve cases.

With such tables/columns SQLObject failes to create constraint because the constraint naming rule simply appends '_exists' after the names.

Say I have a ForeignKey constraint like this;

class Order(SQLObject):
class sqlmeta:
table = '"Order"'
...
store = ForeignKey('Store', dbName='"StoreID"')

This definition generates a wrong SQL like this;

ALTER TABLE "Order" ADD CONSTRAINT "StoreID"_exists FOREIGN ...

It's a simple problem that _exists need to be inside of the quote if original name is quoted by "".

Discussion