Commit 5aea10ec authored by zYne's avatar zYne

--no commit message

--no commit message
parent 54e5f45c
...@@ -811,20 +811,19 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -811,20 +811,19 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
case 'mysql': case 'mysql':
// mysql doesn't support LIMIT in subqueries // mysql doesn't support LIMIT in subqueries
$list = $this->_conn->execute($subquery, $params)->fetchAll(Doctrine::FETCH_COLUMN); $list = $this->_conn->execute($subquery, $params)->fetchAll(Doctrine::FETCH_COLUMN);
$subquery = $this->inConditionFromArray($list); $subquery = implode(', ', array_map(array($this->_conn, 'quote'), $list));
break; break;
case 'pgsql': case 'pgsql':
// pgsql needs special nested LIMIT subquery // pgsql needs special nested LIMIT subquery
$subquery = ' IN (SELECT doctrine_subquery_alias.' . $table->getIdentifier(). ' FROM (' . $subquery . ') AS doctrine_subquery_alias)'; $subquery = 'SELECT doctrine_subquery_alias.' . $table->getIdentifier(). ' FROM (' . $subquery . ') AS doctrine_subquery_alias';
break; break;
} }
$field = $this->getTableAlias($rootAlias) . '.' . $table->getIdentifier(); $field = $this->getTableAlias($rootAlias) . '.' . $table->getIdentifier();
// only append the subquery if it actually contains something // only append the subquery if it actually contains something
if ($subquery !== '') if ($subquery !== '') {
{ array_unshift($this->parts['where'], $this->_conn->quoteIdentifier($field) . ' IN (' . $subquery . ')');
array_unshift($this->parts['where'], $this->_conn->quoteIdentifier($field) . $subquery);
} }
$modifyLimit = false; $modifyLimit = false;
...@@ -1275,39 +1274,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -1275,39 +1274,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
return $this->_aliasMap[$componentAlias]; return $this->_aliasMap[$componentAlias];
} }
/**
* inConditionFromArray
*
* explode array into quoted array (quick and dirty)
*
* @param array $values
*
* @return mixed - SQL list of conditions passed, or false if empty
*/
//TODO: check column type instead of first array value?
//TODO: is there cleaner value quoting as part of Doctrine somewhere?
public function inConditionFromArray(array $values)
{
if (empty($values))
return false;
$list_values = ' IN (';
// is first value a string? then assume column is.
if (is_string($values[0]))
{
foreach ($values as &$value)
{
$value = '\'' . $value . '\'';
}
}
$list_values .= implode(', ', $values);
$list_values .= ')';
return $list_values;
}
/** /**
* loadRoot * loadRoot
* *
......
...@@ -62,6 +62,15 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase ...@@ -62,6 +62,15 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($q->getQuery(), 'SELECT "e.id" AS "e__id", "e.name" AS "e__name" FROM "entity" "e" WHERE "e.id" = 3 AND ("e.type" = 0)'); $this->assertEqual($q->getQuery(), 'SELECT "e.id" AS "e__id", "e.name" AS "e__name" FROM "entity" "e" WHERE "e.id" = 3 AND ("e.type" = 0)');
} }
public function testQuerySupportsIdentifierQuotingWorksWithinFunctions()
{
$q = new Doctrine_Query();
$q->parseQuery("SELECT u.name FROM User u WHERE TRIM(u.name) = 'zYne'");
$this->assertEqual($q->getQuery(), 'SELECT "e.id" AS "e__id", "e.name" AS "e__name" FROM "entity" "e" WHERE TRIM(u.name) = 3 AND ("e.type" = 0)');
}
public function testQuerySupportsIdentifierQuotingWithJoins() public function testQuerySupportsIdentifierQuotingWithJoins()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
......
...@@ -42,7 +42,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -42,7 +42,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
parent::prepareTables(); parent::prepareTables();
} }
/**
public function testLimitWithOneToOneLeftJoin() public function testLimitWithOneToOneLeftJoin()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
...@@ -62,7 +62,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -62,7 +62,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users->count(), 5); $this->assertEqual($users->count(), 5);
$this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id, e2.address AS e2__address FROM entity e INNER JOIN email e2 ON e.email_id = e2.id WHERE (e.type = 0) LIMIT 5"); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e2.id AS e2__id, e2.address AS e2__address FROM entity e INNER JOIN email e2 ON e.email_id = e2.id WHERE (e.type = 0) LIMIT 5");
} }
*/
public function testLimitWithOneToManyLeftJoin() public function testLimitWithOneToManyLeftJoin()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
......
...@@ -243,6 +243,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -243,6 +243,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
$q->execute(array('verified')); $q->execute(array('verified'));
} }
public function testEnumValuesWorkWithMultiplePlaceholders() public function testEnumValuesWorkWithMultiplePlaceholders()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
...@@ -256,6 +257,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -256,6 +257,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
$this->assertTrue(empty($p[0])); $this->assertTrue(empty($p[0]));
$q->execute(array(1, 'verified')); $q->execute(array(1, 'verified'));
} }
public function testEnumValuesWorkWithMultipleNamedPlaceholders() public function testEnumValuesWorkWithMultipleNamedPlaceholders()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
......
...@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests'); ...@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
$test->addTestCase(new Doctrine_Ticket330_TestCase()); $test->addTestCase(new Doctrine_Ticket330_TestCase());
*/ */
/** */
// Connection drivers (not yet fully tested) // Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase()); $test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase()); $test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
...@@ -249,7 +249,7 @@ $test->addTestCase(new Doctrine_Query_Limit_TestCase()); ...@@ -249,7 +249,7 @@ $test->addTestCase(new Doctrine_Query_Limit_TestCase());
$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase()); //$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase()); $test->addTestCase(new Doctrine_Query_Update_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase()); $test->addTestCase(new Doctrine_Query_Delete_TestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment