Doctrine 1
  1. Doctrine 1
  2. DC-130

Doctrine::generateModelsFromDb fails on foreign key relationships with certain table names on Postgresql

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1.4, 1.2.0-ALPHA2
    • Fix Version/s: 1.0.13, 1.1.5, 1.2.0-BETA1
    • Component/s: Import/Export
    • Labels:
      None
    • Environment:
      Ubuntu 9.04 postgresql-8.3

      Description

      Create the following tables:

      CREATE TABLE "user" (
      id serial PRIMARY KEY,
      name varchar(30) NOT NULL
      );

      CREATE TABLE "group" (
      id serial PRIMARY KEY,
      name varchar(30) NOT NULL
      );

      CREATE TABLE "user_x_group" (
      id serial PRIMARY KEY,
      user_id int NOT NULL REFERENCES "user" ( id ),
      group_id int NOT NULL REFERENCES "group" ( id ),
      UNIQUE ( user_id, group_id )
      );

      If you try to run Doctrine::generateModelsFromDb() it will crash with
      Uncaught exception 'Doctrine_Import_Builder_Exception' with message 'Missing class name.'

      This is caused by the fact that the table 'user' (and 'group' also, for that matter) is escaped with quotes when
      passed through pg_get_constraintdef, because 'user' (and 'group') is a reserved word.

      A solution would be to modifiy the regexp in Doctrine_Import_Pgsql::listTableRelations so that it strips the quote characters
      from identifiers.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Michiel Boland
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: