Doctrine 1
  1. Doctrine 1
  2. DC-919

Import/Pgsql.php: listTableColumns - SQL failure with PostgreSQL

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Import/Export
    • Labels:
      None
    • Environment:
      Postgres Import Schema

      Description

      Hi,

      this issue was reported at the symfony project which uses Doctrine 1.2.3:
      http://trac.symfony-project.org/ticket/9152
      "php symfony doctrine:build-schema failure with PostgreSQL for 1.4.7 and 1.4.8 version"

      The SQL Statement 'listTableColumns' fails with an SQL-Error "missing from-clause"
      http://trac.doctrine-project.org/browser/tags/1.2.3/lib/Doctrine/Import/Pgsql.php#L96
      I can reproduce the error directly in psql or pgadmin. The SQL Statement seems related to DC-697

      Even when i turn on the add_missing_from option on the postgres-server it fails with "missing relation".

      Now it seems to me, you already fixed this bug in the current 1.2 branch, because the current SQL-Statement is different and it works for me in psql/pgadmin.
      http://trac.doctrine-project.org/browser/branches/1.2/lib/Doctrine/Import/Pgsql.php#L96

      Could you please close this ticket, if you already fixed this issue, or confirm if it's still an issue?
      Attached you find my proposed patch at the symfony project . the current statement in the branch looks too different from my version, so i am not sure to use this patch directly. Tell me if I should work out a proper patch.

      error
      SQLSTATE[42P01]: Undefined table: 7 ERROR:  missing FROM-clause entry for table "t"                                               
       	  LINE 6: ...                                                  t.typtype ...                                                       
       	                                                               ^. Failing Query: "SELECT                                           
       	                                                       ordinal_position as attnum,                                                 
       	                                                       column_name as field,                                                       
       	                                                       udt_name as type,                                                           
       	                                                       data_type as complete_type,                                                 
       	                                                       t.typtype AS typtype,                                                       
       	                                                       is_nullable as isnotnull,                                                   
       	                                                       column_default as default,                                                   
       	                                                       (                                                                           
       	                                                         SELECT 't'                                                                 
       	                                                           FROM pg_index, pg_attribute a, pg_class c, pg_type t                     
       	                                                           WHERE c.relname = table_name AND a.attname = column_name                 
       	                                                           AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid           
       	                                                           AND c.oid = pg_index.indrelid AND a.attnum = ANY (pg_index.indkey)       
       	                                                           AND pg_index.indisprimary = 't'                                         
       	                                                           AND format_type(a.atttypid, a.atttypmod) NOT LIKE 'information_schema%' 
       	                                                       ) as pri,                                                                   
       	                                                       character_maximum_length as length                                           
       	                                                     FROM information_schema.COLUMNS                                               
       	                                                     WHERE table_name = 'matable'                                   
       	                                                     ORDER BY ordinal_position"  
      

        Activity

        Hide
        Cesar Miggiolaro added a comment -

        I use the version 1.4.17 and also had the error with postgres 9.1. Applying the correction suggested in DIFF. The system worked.

        Show
        Cesar Miggiolaro added a comment - I use the version 1.4.17 and also had the error with postgres 9.1. Applying the correction suggested in DIFF. The system worked.
        Hide
        David Landgren added a comment -

        Confirmed to fix crash with symfony 1.3.8

        Show
        David Landgren added a comment - Confirmed to fix crash with symfony 1.3.8
        Hide
        Christopher Hotchkiss added a comment -

        I can confirm that this bug also affects symfony 1.4.8 and the attached fix works perfectly!

        Show
        Christopher Hotchkiss added a comment - I can confirm that this bug also affects symfony 1.4.8 and the attached fix works perfectly!
        Hide
        Tim Hemming added a comment -

        We have applied this patch directly to our server-wide Doctrine library and it works fine. We look forward to it becoming a part of the Doctrine distribution.

        Show
        Tim Hemming added a comment - We have applied this patch directly to our server-wide Doctrine library and it works fine. We look forward to it becoming a part of the Doctrine distribution.
        Hide
        Nahuel Alejandro Ramos added a comment -

        We apply the diff patch you submit and works perfect. We are using Doctrine 1.2.3 with PostgreSQL 8.4.
        We could generates models from database with generateModelsFromDb() method.
        Please add this patch to a new release.
        Thank you very much.

        Show
        Nahuel Alejandro Ramos added a comment - We apply the diff patch you submit and works perfect. We are using Doctrine 1.2.3 with PostgreSQL 8.4. We could generates models from database with generateModelsFromDb() method. Please add this patch to a new release. Thank you very much.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Christian Vogel
          • Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: