Issues

ZF-7758: Zend_Db_Table and join = table/alias lowercased

Issue Type: Bug Created: 2009-09-02T06:53:04.000+0000 Last Updated: 2009-10-30T11:01:36.000+0000 Status: Closed Fix version(s): Reporter: Marek (xorock) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Db_Table

Related issues: Attachments:

Description

Adapter used: Pdo_Pgsql Tablename: camelCase Code:

<pre class="highlight"> 
$select = $xTable->select()
            ->setIntegrityCheck(false)
            ->from($xTable, array('action' => 'name'))
            ->joinInner...

Error: SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "camelcase" #table is lowercased

Manual query

<pre class="highlight"> 
$select = $xTable->select()
            ->setIntegrityCheck(false)
            ->from('camelCase', array('action' => 'name'))
            ->joinInner...

will work as expected.

Edit: Same problem with aliasing.

<pre class="highlight">
->joinLeft(array('pGroups' => 'groups')... #pGroups will become pgroups

Comments

Posted by Ramon Henrique Ornelas (ramon) on 2009-10-25T17:27:11.000+0000

Not issue in ZF.

See http://framework.zend.com/manual/en/…

See http://postgresql.org/docs/8.4/…

Posted by Marek (xorock) on 2009-10-28T10:42:40.000+0000

Why it's not a ZF issue? Postgresql error code 42P01 means UNDEFINED TABLE. Table is defined as protected $_name = 'camelCase'; Query generated by ZF tries to access table which name is lowercased to "camelcase" and thus exception is thrown. As You can see this only happens when object is passed to select->from method.

Posted by Ramon Henrique Ornelas (ramon) on 2009-10-29T10:36:20.000+0000

I performed several tests.

In version 1.9.2 and in trunk no problem.

Analize the string generated Zend_Db_Table_Select.

Can help.

--query error SELECT "camelCase".* FROM camelCase; --error: SQL state: 42P01

--query error SELECT camelCase.* FROM "camelCase"; --error: SQL state: 42P01

--query success SELECT "camelCase".* FROM "camelCase";

Note quotation marks in the table.

Posted by Marek (xorock) on 2009-10-30T09:32:34.000+0000

Yes, with simple select this is ok, but try inner join.

<pre class="highlight">
CREATE TABLE some."teSt"
(
  id integer NOT NULL DEFAULT nextval('some."teSt_id_seq"'::regclass),
  CONSTRAINT "teSt_pkey" PRIMARY KEY (id)
)

class Default_Model_DbTable_Test extends Zend_Db_Table_Abstract {
  protected $_name = 'teSt';
}

$xTable = new Default_Model_DbTable_Test();
$select = $xTable->select()
            ->setIntegrityCheck(false)
            ->from($xTable, array('action' => 'name'))
#fetch - this is ok, profiler: SELECT "teSt"."name" AS "action" FROM "some"."teSt"

$select = $xTable->select()
            ->setIntegrityCheck(false)
            ->from($xTable, array('action' => 'name'))
            ->joinInner('a', 'a.id = teSt.id');
#fetch - SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "test" LINE 2: INNER JOIN...

Please ask if You need some more info.

Posted by Ramon Henrique Ornelas (ramon) on 2009-10-30T11:01:35.000+0000

your code

<pre class="highlight">  
$select = $table->select()
           ->setIntegrityCheck(false)
           ->from($table, array('action' => 'name'))
           ->joinInner('a', 'a.id = teSt.id');

alter for

<pre class="highlight">
$select = $table->select()
           ->setIntegrityCheck(false)
           ->from($table, array('action' => 'name'))
           ->joinInner('a', 'a.id = "teSt".id');

problem in ->joinInner('a', 'a.id = teSt.id');

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts