Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 1.2.0-ALPHA3
-
Fix Version/s: 1.2.0-BETA1
-
Component/s: None
-
Labels:None
-
Environment:PostgreSQL 8.1, PHP 5.2
Description
I'm getting an exception when generating models from db because I have a table named 'role' which is a reserved word, as you can see at http://www.postgresql.org/docs/8.1/static/sql-keywords-appendix.html
I have a table named 'role_permission' which has a foreign key pointing to table 'role'. When Doctrine tries to find the related tables using 'Doctrine_Import_Pgsql::listTableRelations()', the executed SQL returns:
FOREIGN KEY (role_id) REFERENCES "role"(role_id) ON DELETE CASCADE
with the table name role quoted as it is a reserved word.
My workaround is to change Doctrine_Import_Pgsql line 281 from:
$relations[] = array('table' => $values[2],
to:
$relations[] = array('table' => (strpos($values[2],'"') === 0)?substr($values[2],1,-1):$values[2],
This was already fixed last night.