Commit f2f8adcc authored by Benjamin Eberlei's avatar Benjamin Eberlei

Revert "Quoting Table name" affecting GH-335

Introduced BC break with databases that switch from case-insensitive
to case-senstive handling when identifier quoting is enabled.

This reverts commit 11111bd7.
parent 958efa3e
...@@ -951,7 +951,7 @@ class QueryBuilder ...@@ -951,7 +951,7 @@ class QueryBuilder
// Loop through all FROM clauses // Loop through all FROM clauses
foreach ($this->sqlParts['from'] as $from) { foreach ($this->sqlParts['from'] as $from) {
$knownAliases[$from['alias']] = true; $knownAliases[$from['alias']] = true;
$fromClause = $this->connection->quoteIdentifier($from['table']) . ' ' . $from['alias'] $fromClause = $from['table'] . ' ' . $from['alias']
. $this->getSQLForJoins($from['alias'], $knownAliases); . $this->getSQLForJoins($from['alias'], $knownAliases);
$fromClauses[$from['alias']] = $fromClause; $fromClauses[$from['alias']] = $fromClause;
...@@ -981,7 +981,7 @@ class QueryBuilder ...@@ -981,7 +981,7 @@ class QueryBuilder
*/ */
private function getSQLForUpdate() private function getSQLForUpdate()
{ {
$table = $this->connection->quoteIdentifier($this->sqlParts['from']['table']) . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : ''); $table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
$query = 'UPDATE ' . $table $query = 'UPDATE ' . $table
. ' SET ' . implode(", ", $this->sqlParts['set']) . ' SET ' . implode(", ", $this->sqlParts['set'])
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : ''); . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
...@@ -996,7 +996,7 @@ class QueryBuilder ...@@ -996,7 +996,7 @@ class QueryBuilder
*/ */
private function getSQLForDelete() private function getSQLForDelete()
{ {
$table = $this->connection->quoteIdentifier($this->sqlParts['from']['table']) . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : ''); $table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
$query = 'DELETE FROM ' . $table . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : ''); $query = 'DELETE FROM ' . $table . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
return $query; return $query;
...@@ -1086,7 +1086,7 @@ class QueryBuilder ...@@ -1086,7 +1086,7 @@ class QueryBuilder
if (isset($this->sqlParts['join'][$fromAlias])) { if (isset($this->sqlParts['join'][$fromAlias])) {
foreach ($this->sqlParts['join'][$fromAlias] as $join) { foreach ($this->sqlParts['join'][$fromAlias] as $join) {
$sql .= ' ' . strtoupper($join['joinType']) $sql .= ' ' . strtoupper($join['joinType'])
. ' JOIN ' . $this->connection->quoteIdentifier($join['joinTable']) . ' ' . $join['joinAlias'] . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
. ' ON ' . ((string) $join['joinCondition']); . ' ON ' . ((string) $join['joinCondition']);
$knownAliases[$join['joinAlias']] = true; $knownAliases[$join['joinAlias']] = true;
......
...@@ -23,15 +23,6 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -23,15 +23,6 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$this->conn->expects($this->any()) $this->conn->expects($this->any())
->method('getExpressionBuilder') ->method('getExpressionBuilder')
->will($this->returnValue($expressionBuilder)); ->will($this->returnValue($expressionBuilder));
$this->conn->expects($this->any())
->method('quoteIdentifier')
->will(
$this->returnCallback(
function($tableName){
return "`{$tableName}`";
}
)
);
} }
public function testSimpleSelect() public function testSimpleSelect()
...@@ -41,7 +32,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -41,7 +32,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->select('u.id') $qb->select('u.id')
->from('users', 'u'); ->from('users', 'u');
$this->assertEquals('SELECT u.id FROM `users` u', (string) $qb); $this->assertEquals('SELECT u.id FROM users u', (string) $qb);
} }
public function testSelectWithSimpleWhere() public function testSelectWithSimpleWhere()
...@@ -53,7 +44,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -53,7 +44,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->where($expr->andX($expr->eq('u.nickname', '?'))); ->where($expr->andX($expr->eq('u.nickname', '?')));
$this->assertEquals("SELECT u.id FROM `users` u WHERE u.nickname = ?", (string) $qb); $this->assertEquals("SELECT u.id FROM users u WHERE u.nickname = ?", (string) $qb);
} }
public function testSelectWithLeftJoin() public function testSelectWithLeftJoin()
...@@ -65,7 +56,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -65,7 +56,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->leftJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); ->leftJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM `users` u LEFT JOIN `phones` p ON p.user_id = u.id', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u LEFT JOIN phones p ON p.user_id = u.id', (string) $qb);
} }
public function testSelectWithJoin() public function testSelectWithJoin()
...@@ -77,7 +68,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -77,7 +68,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->Join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); ->Join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM `users` u INNER JOIN `phones` p ON p.user_id = u.id', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb);
} }
public function testSelectWithInnerJoin() public function testSelectWithInnerJoin()
...@@ -89,7 +80,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -89,7 +80,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->innerJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); ->innerJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM `users` u INNER JOIN `phones` p ON p.user_id = u.id', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb);
} }
public function testSelectWithRightJoin() public function testSelectWithRightJoin()
...@@ -101,7 +92,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -101,7 +92,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->rightJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); ->rightJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM `users` u RIGHT JOIN `phones` p ON p.user_id = u.id', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb);
} }
public function testSelectWithAndWhereConditions() public function testSelectWithAndWhereConditions()
...@@ -114,7 +105,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -114,7 +105,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->where('u.username = ?') ->where('u.username = ?')
->andWhere('u.name = ?'); ->andWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb);
} }
public function testSelectWithOrWhereConditions() public function testSelectWithOrWhereConditions()
...@@ -127,7 +118,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -127,7 +118,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->where('u.username = ?') ->where('u.username = ?')
->orWhere('u.name = ?'); ->orWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
} }
public function testSelectWithOrOrWhereConditions() public function testSelectWithOrOrWhereConditions()
...@@ -140,7 +131,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -140,7 +131,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->orWhere('u.username = ?') ->orWhere('u.username = ?')
->orWhere('u.name = ?'); ->orWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
} }
public function testSelectWithAndOrWhereConditions() public function testSelectWithAndOrWhereConditions()
...@@ -155,7 +146,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -155,7 +146,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->orWhere('u.name = ?') ->orWhere('u.name = ?')
->andWhere('u.name = ?'); ->andWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb);
} }
public function testSelectGroupBy() public function testSelectGroupBy()
...@@ -167,7 +158,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -167,7 +158,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->groupBy('u.id'); ->groupBy('u.id');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb);
} }
public function testSelectEmptyGroupBy() public function testSelectEmptyGroupBy()
...@@ -179,7 +170,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -179,7 +170,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->groupBy(array()) ->groupBy(array())
->from('users', 'u'); ->from('users', 'u');
$this->assertEquals('SELECT u.*, p.* FROM `users` u', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
} }
public function testSelectEmptyAddGroupBy() public function testSelectEmptyAddGroupBy()
...@@ -191,7 +182,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -191,7 +182,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->addGroupBy(array()) ->addGroupBy(array())
->from('users', 'u'); ->from('users', 'u');
$this->assertEquals('SELECT u.*, p.* FROM `users` u', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
} }
public function testSelectAddGroupBy() public function testSelectAddGroupBy()
...@@ -204,7 +195,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -204,7 +195,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->groupBy('u.id') ->groupBy('u.id')
->addGroupBy('u.foo'); ->addGroupBy('u.foo');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id, u.foo', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb);
} }
public function testSelectAddGroupBys() public function testSelectAddGroupBys()
...@@ -217,7 +208,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -217,7 +208,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->groupBy('u.id') ->groupBy('u.id')
->addGroupBy('u.foo', 'u.bar'); ->addGroupBy('u.foo', 'u.bar');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id, u.foo, u.bar', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb);
} }
public function testSelectHaving() public function testSelectHaving()
...@@ -230,7 +221,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -230,7 +221,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->groupBy('u.id') ->groupBy('u.id')
->having('u.name = ?'); ->having('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id HAVING u.name = ?', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
} }
public function testSelectAndHaving() public function testSelectAndHaving()
...@@ -243,7 +234,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -243,7 +234,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->groupBy('u.id') ->groupBy('u.id')
->andHaving('u.name = ?'); ->andHaving('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id HAVING u.name = ?', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
} }
public function testSelectHavingAndHaving() public function testSelectHavingAndHaving()
...@@ -257,7 +248,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -257,7 +248,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->having('u.name = ?') ->having('u.name = ?')
->andHaving('u.username = ?'); ->andHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb);
} }
public function testSelectHavingOrHaving() public function testSelectHavingOrHaving()
...@@ -271,7 +262,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -271,7 +262,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->having('u.name = ?') ->having('u.name = ?')
->orHaving('u.username = ?'); ->orHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb);
} }
public function testSelectOrHavingOrHaving() public function testSelectOrHavingOrHaving()
...@@ -285,7 +276,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -285,7 +276,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->orHaving('u.name = ?') ->orHaving('u.name = ?')
->orHaving('u.username = ?'); ->orHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb);
} }
public function testSelectHavingAndOrHaving() public function testSelectHavingAndOrHaving()
...@@ -300,7 +291,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -300,7 +291,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->orHaving('u.username = ?') ->orHaving('u.username = ?')
->andHaving('u.username = ?'); ->andHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM `users` u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb);
} }
public function testSelectOrderBy() public function testSelectOrderBy()
...@@ -312,7 +303,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -312,7 +303,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->orderBy('u.name'); ->orderBy('u.name');
$this->assertEquals('SELECT u.*, p.* FROM `users` u ORDER BY u.name ASC', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb);
} }
public function testSelectAddOrderBy() public function testSelectAddOrderBy()
...@@ -325,7 +316,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -325,7 +316,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->orderBy('u.name') ->orderBy('u.name')
->addOrderBy('u.username', 'DESC'); ->addOrderBy('u.username', 'DESC');
$this->assertEquals('SELECT u.*, p.* FROM `users` u ORDER BY u.name ASC, u.username DESC', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
} }
public function testSelectAddAddOrderBy() public function testSelectAddAddOrderBy()
...@@ -338,7 +329,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -338,7 +329,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->addOrderBy('u.name') ->addOrderBy('u.name')
->addOrderBy('u.username', 'DESC'); ->addOrderBy('u.username', 'DESC');
$this->assertEquals('SELECT u.*, p.* FROM `users` u ORDER BY u.name ASC, u.username DESC', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
} }
public function testEmptySelect() public function testEmptySelect()
...@@ -359,7 +350,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -359,7 +350,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->addSelect('p.*') ->addSelect('p.*')
->from('users', 'u'); ->from('users', 'u');
$this->assertEquals('SELECT u.*, p.* FROM `users` u', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
} }
public function testEmptyAddSelect() public function testEmptyAddSelect()
...@@ -381,7 +372,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -381,7 +372,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->from('users', 'u') ->from('users', 'u')
->from('phonenumbers', 'p'); ->from('phonenumbers', 'p');
$this->assertEquals('SELECT u.*, p.* FROM `users` u, `phonenumbers` p', (string) $qb); $this->assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb);
} }
public function testUpdate() public function testUpdate()
...@@ -392,7 +383,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -392,7 +383,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->set('u.bar', '?'); ->set('u.bar', '?');
$this->assertEquals(QueryBuilder::UPDATE, $qb->getType()); $this->assertEquals(QueryBuilder::UPDATE, $qb->getType());
$this->assertEquals('UPDATE `users` u SET u.foo = ?, u.bar = ?', (string) $qb); $this->assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb);
} }
public function testUpdateWithoutAlias() public function testUpdateWithoutAlias()
...@@ -402,7 +393,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -402,7 +393,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->set('foo', '?') ->set('foo', '?')
->set('bar', '?'); ->set('bar', '?');
$this->assertEquals('UPDATE `users` SET foo = ?, bar = ?', (string) $qb); $this->assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb);
} }
public function testUpdateWhere() public function testUpdateWhere()
...@@ -412,7 +403,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -412,7 +403,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->set('u.foo', '?') ->set('u.foo', '?')
->where('u.foo = ?'); ->where('u.foo = ?');
$this->assertEquals('UPDATE `users` u SET u.foo = ? WHERE u.foo = ?', (string) $qb); $this->assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb);
} }
public function testEmptyUpdate() public function testEmptyUpdate()
...@@ -430,7 +421,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -430,7 +421,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->delete('users', 'u'); $qb->delete('users', 'u');
$this->assertEquals(QueryBuilder::DELETE, $qb->getType()); $this->assertEquals(QueryBuilder::DELETE, $qb->getType());
$this->assertEquals('DELETE FROM `users` u', (string) $qb); $this->assertEquals('DELETE FROM users u', (string) $qb);
} }
public function testDeleteWithoutAlias() public function testDeleteWithoutAlias()
...@@ -439,7 +430,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -439,7 +430,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->delete('users'); $qb->delete('users');
$this->assertEquals(QueryBuilder::DELETE, $qb->getType()); $this->assertEquals(QueryBuilder::DELETE, $qb->getType());
$this->assertEquals('DELETE FROM `users`', (string) $qb); $this->assertEquals('DELETE FROM users', (string) $qb);
} }
public function testDeleteWhere() public function testDeleteWhere()
...@@ -448,7 +439,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -448,7 +439,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->delete('users', 'u') $qb->delete('users', 'u')
->where('u.foo = ?'); ->where('u.foo = ?');
$this->assertEquals('DELETE FROM `users` u WHERE u.foo = ?', (string) $qb); $this->assertEquals('DELETE FROM users u WHERE u.foo = ?', (string) $qb);
} }
public function testEmptyDelete() public function testEmptyDelete()
...@@ -506,9 +497,9 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -506,9 +497,9 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->select('u.*')->from('users', 'u')->where('u.name = ?'); $qb->select('u.*')->from('users', 'u')->where('u.name = ?');
$this->assertEquals('SELECT u.* FROM `users` u WHERE u.name = ?', (string)$qb); $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb);
$qb->resetQueryPart('where'); $qb->resetQueryPart('where');
$this->assertEquals('SELECT u.* FROM `users` u', (string)$qb); $this->assertEquals('SELECT u.* FROM users u', (string)$qb);
} }
public function testResetQueryParts() public function testResetQueryParts()
...@@ -517,9 +508,9 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -517,9 +508,9 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name'); $qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name');
$this->assertEquals('SELECT u.* FROM `users` u WHERE u.name = ? ORDER BY u.name ASC', (string)$qb); $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ? ORDER BY u.name ASC', (string)$qb);
$qb->resetQueryParts(array('where', 'orderBy')); $qb->resetQueryParts(array('where', 'orderBy'));
$this->assertEquals('SELECT u.* FROM `users` u', (string)$qb); $this->assertEquals('SELECT u.* FROM users u', (string)$qb);
} }
public function testCreateNamedParameter() public function testCreateNamedParameter()
...@@ -530,7 +521,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -530,7 +521,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT)) $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT))
); );
$this->assertEquals('SELECT u.* FROM `users` u WHERE u.name = :dcValue1', (string)$qb); $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :dcValue1', (string)$qb);
$this->assertEquals(10, $qb->getParameter('dcValue1')); $this->assertEquals(10, $qb->getParameter('dcValue1'));
} }
...@@ -542,7 +533,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -542,7 +533,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT, ':test')) $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT, ':test'))
); );
$this->assertEquals('SELECT u.* FROM `users` u WHERE u.name = :test', (string)$qb); $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :test', (string)$qb);
$this->assertEquals(10, $qb->getParameter('test')); $this->assertEquals(10, $qb->getParameter('test'));
} }
...@@ -554,7 +545,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -554,7 +545,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT)) $qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT))
); );
$this->assertEquals('SELECT u.* FROM `users` u WHERE u.name = ?', (string)$qb); $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb);
$this->assertEquals(10, $qb->getParameter(1)); $this->assertEquals(10, $qb->getParameter(1));
} }
...@@ -591,7 +582,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -591,7 +582,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->where('nt.lang = ?') ->where('nt.lang = ?')
->andWhere('n.deleted = 0'); ->andWhere('n.deleted = 0');
$this->assertEquals("SELECT COUNT(DISTINCT news.id) FROM `newspages` news INNER JOIN `nodeversion` nv ON nv.refId = news.id AND nv.refEntityname='Entity\\News' INNER JOIN `nodetranslation` nt ON nv.nodetranslation = nt.id INNER JOIN `node` n ON nt.node = n.id WHERE (nt.lang = ?) AND (n.deleted = 0)", $qb->getSQL()); $this->assertEquals("SELECT COUNT(DISTINCT news.id) FROM newspages news INNER JOIN nodeversion nv ON nv.refId = news.id AND nv.refEntityname='Entity\\News' INNER JOIN nodetranslation nt ON nv.nodetranslation = nt.id INNER JOIN node n ON nt.node = n.id WHERE (nt.lang = ?) AND (n.deleted = 0)", $qb->getSQL());
} }
/** /**
...@@ -609,7 +600,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase ...@@ -609,7 +600,7 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->where('u.id = a.user_id') ->where('u.id = a.user_id')
->andWhere('p.read = 1'); ->andWhere('p.read = 1');
$this->assertEquals('SELECT DISTINCT u.id FROM `users` u INNER JOIN `permissions` p ON p.user_id = u.id, `articles` a INNER JOIN `comments` c ON c.article_id = a.id WHERE (u.id = a.user_id) AND (p.read = 1)', $qb->getSQL()); $this->assertEquals('SELECT DISTINCT u.id FROM users u INNER JOIN permissions p ON p.user_id = u.id, articles a INNER JOIN comments c ON c.article_id = a.id WHERE (u.id = a.user_id) AND (p.read = 1)', $qb->getSQL());
} }
public function testClone() public function testClone()
......
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