Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-614

Multiple Entities in FROM clause throws exception

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA1
    • Fix Version/s: 2.0-BETA3
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None
    • Environment:
      PostgreSql 8.4

      Description

      When I query,

      SELECT k, d FROM OneMind\Domain\Sales\Kendaraan k, OneMind\Domain\Sales\DeliveryOrder d
      

      it raises exception:

      SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "d1_" 
      LINE 1: ...gan AS pelanggan8, k0_.keterangan AS keterangan9, d1_.id AS ... ^ 
      

      then I try to var_dump the sql:

      SELECT k0_.id AS id0, k0_.tipe_kendaraan AS tipe_kendaraan1, k0_.warna AS warna2, k0_.no_rangka AS no_rangka3,
       k0_.no_mesin AS no_mesin4, k0_.tahun AS tahun5, k0_.rrn AS rrn6, k0_.salesman AS salesman7, k0_.pelanggan AS 
      pelanggan8, k0_.keterangan AS keterangan9, d1_.id AS id10, d1_.nomor AS nomor11, d1_.tanggal AS tanggal12, 
      d1_.kode_supplier AS kode_supplier13, d1_.tipe_kendaraan AS tipe_kendaraan14, d1_.warna AS warna15, 
      d1_.no_rangka AS no_rangka16, d1_.no_mesin AS no_mesin17, d1_.tahun AS tahun18, d1_.harga_beli AS harga_beli19, 
      d1_.no_sap AS no_sap20, d1_.tgl_sap AS tgl_sap21, d1_.dpp AS dpp22, d1_.ppn_masuk AS ppn_masuk23, d1_.bunga 
      AS bunga24, d1_.jatuh_tempo AS jatuh_tempo25, d1_.rrn AS rrn26 FROM kendaraan k0_
      
      

      Only the first entity appears in SQL FROM clause. The second one is missing. It is likely affect JOIN as well.

        Issue Links

          Activity

          Hide
          Felix-Johannes Jendrusch added a comment -

          PDOException

          SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "t2_" LINE 1: ...N terminal_file t1_ ON f0_.id = t1_.file_ref AND (t2_.id IN ... ^'
          

          Join

                                  $qb->innerJoin('f.terminals', 'cts', Expr\Join::WITH,
                                          $qb->expr()->in('cts.terminalRef.id', array_map(function($value) {
                                              return (integer) $value;
                                          }, (array) $value)));
          

          DQL

          SELECT f FROM [...]\File f INNER JOIN f.terminals cts WITH cts.terminalRef.id IN(5) [...]
          

          SQL

          SELECT [...] FROM file f0_ INNER JOIN terminal_file t1_ ON f0_.id = t1_.file_ref AND (t2_.id IN (5)) INNER JOIN terminal t2_ ON t1_.terminal_ref = t2_.id [...]
          
          Show
          Felix-Johannes Jendrusch added a comment - PDOException SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "t2_" LINE 1: ...N terminal_file t1_ ON f0_.id = t1_.file_ref AND (t2_.id IN ... ^' Join $qb->innerJoin('f.terminals', 'cts', Expr\Join::WITH, $qb->expr()->in('cts.terminalRef.id', array_map(function($value) { return (integer) $value; }, (array) $value))); DQL SELECT f FROM [...]\File f INNER JOIN f.terminals cts WITH cts.terminalRef.id IN(5) [...] SQL SELECT [...] FROM file f0_ INNER JOIN terminal_file t1_ ON f0_.id = t1_.file_ref AND (t2_.id IN (5)) INNER JOIN terminal t2_ ON t1_.terminal_ref = t2_.id [...]
          Show
          Guilherme Blanco added a comment - On http://github.com/doctrine/doctrine2/commit/2c28872af820a27b36e4ff3ca28ef92ea8c1f0f3 this issue was fixed.

            People

            • Assignee:
              Guilherme Blanco
              Reporter:
              Andy Aja deh
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: