|
|
@@ -196,7 +196,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['title', 'name'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->order(['title' => 'asc'])
|
|
|
->execute();
|
|
|
|
|
|
@@ -208,7 +208,7 @@ class QueryTest extends TestCase
|
|
|
$this->assertCount(12, $result, 'Cross join results in 12 records');
|
|
|
|
|
|
$result = $query->join([
|
|
|
- ['table' => 'authors', 'type' => 'INNER', 'conditions' => 'author_id = authors.id']
|
|
|
+ ['table' => 'authors', 'type' => 'INNER', 'conditions' => $query->newExpr()->equalFields('author_id', 'authors.id')]
|
|
|
], [], true)->execute();
|
|
|
$this->assertCount(3, $result);
|
|
|
$this->assertEquals(['title' => 'First Article', 'name' => 'mariano'], $result->fetch('assoc'));
|
|
|
@@ -226,14 +226,14 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['title', 'name'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => ['author_id = a.id']])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => [$query->newExpr()->equalFields('author_id ', 'a.id')]])
|
|
|
->order(['title' => 'asc'])
|
|
|
->execute();
|
|
|
$this->assertEquals(['title' => 'First Article', 'name' => 'mariano'], $result->fetch('assoc'));
|
|
|
$this->assertEquals(['title' => 'Second Article', 'name' => 'larry'], $result->fetch('assoc'));
|
|
|
|
|
|
$query = new Query($this->connection);
|
|
|
- $conditions = $query->newExpr('author_id = a.id');
|
|
|
+ $conditions = $query->newExpr()->equalFields('author_id', 'a.id');
|
|
|
$result = $query
|
|
|
->select(['title', 'name'])
|
|
|
->from('articles')
|
|
|
@@ -1296,7 +1296,7 @@ class QueryTest extends TestCase
|
|
|
->select(['id'])
|
|
|
->from('comments')
|
|
|
->where(function ($exp, $q) {
|
|
|
- $field = $q->newExpr('COALESCE(id, 1)');
|
|
|
+ $field = $q->func()->coalesce([new IdentifierExpression('id'), 1 => 'literal']);
|
|
|
return $exp->between($field, 5, 6, 'integer');
|
|
|
})
|
|
|
->execute();
|
|
|
@@ -1560,7 +1560,7 @@ class QueryTest extends TestCase
|
|
|
$query = new Query($this->connection);
|
|
|
$query->select(['id'])
|
|
|
->from('articles')
|
|
|
- ->orderAsc($query->func()->concat(['id' => 'literal', '3']));
|
|
|
+ ->orderAsc($query->func()->concat(['id' => 'identifier', '3']));
|
|
|
|
|
|
$result = $query->execute()->fetchAll('assoc');
|
|
|
$expected = [
|
|
|
@@ -1599,7 +1599,7 @@ class QueryTest extends TestCase
|
|
|
$query = new Query($this->connection);
|
|
|
$query->select(['id'])
|
|
|
->from('articles')
|
|
|
- ->orderDesc($query->func()->concat(['id' => 'literal', '3']));
|
|
|
+ ->orderDesc($query->func()->concat(['id' => 'identifier', '3']));
|
|
|
|
|
|
$result = $query->execute()->fetchAll('assoc');
|
|
|
$expected = [
|
|
|
@@ -1767,7 +1767,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['total' => 'count(author_id)', 'author_id'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->group('author_id')
|
|
|
->having(['count(author_id) <' => 2], ['count(author_id)' => 'integer'])
|
|
|
->execute();
|
|
|
@@ -1799,7 +1799,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['total' => 'count(author_id)', 'author_id'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->group('author_id')
|
|
|
->having(['count(author_id) >' => 2], ['count(author_id)' => 'integer'])
|
|
|
->orHaving(['count(author_id) <' => 2], ['count(author_id)' => 'integer'])
|
|
|
@@ -1811,7 +1811,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['total' => 'count(author_id)', 'author_id'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->group('author_id')
|
|
|
->having(['count(author_id) >' => 2], ['count(author_id)' => 'integer'])
|
|
|
->orHaving(['count(author_id) <=' => 2], ['count(author_id)' => 'integer'])
|
|
|
@@ -1823,7 +1823,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['total' => 'count(author_id)', 'author_id'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->group('author_id')
|
|
|
->having(['count(author_id) >' => 2], ['count(author_id)' => 'integer'])
|
|
|
->orHaving(function ($e) {
|
|
|
@@ -1846,7 +1846,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['total' => 'count(author_id)', 'author_id'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->group('author_id')
|
|
|
->having(['count(author_id) >' => 2], ['count(author_id)' => 'integer'])
|
|
|
->andHaving(['count(author_id) <' => 2], ['count(author_id)' => 'integer'])
|
|
|
@@ -1857,7 +1857,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['total' => 'count(author_id)', 'author_id'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->group('author_id')
|
|
|
->having(['count(author_id)' => 2], ['count(author_id)' => 'integer'])
|
|
|
->andHaving(['count(author_id) >' => 1], ['count(author_id)' => 'integer'])
|
|
|
@@ -1869,7 +1869,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query
|
|
|
->select(['total' => 'count(author_id)', 'author_id'])
|
|
|
->from('articles')
|
|
|
- ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => 'author_id = a.id'])
|
|
|
+ ->join(['table' => 'authors', 'alias' => 'a', 'conditions' => $query->newExpr()->equalFields('author_id', 'a.id')])
|
|
|
->group('author_id')
|
|
|
->andHaving(function ($e) {
|
|
|
return $e->add('count(author_id) = 2 - 1');
|
|
|
@@ -2005,7 +2005,7 @@ class QueryTest extends TestCase
|
|
|
$subquery = (new Query($this->connection))
|
|
|
->select('name')
|
|
|
->from(['b' => 'authors'])
|
|
|
- ->where(['b.id = a.id']);
|
|
|
+ ->where([$query->newExpr()->equalFields('b.id', 'a.id')]);
|
|
|
$result = $query
|
|
|
->select(['id', 'name' => $subquery])
|
|
|
->from(['a' => 'comments'])->execute();
|
|
|
@@ -2113,7 +2113,7 @@ class QueryTest extends TestCase
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testSubqueyInJoin()
|
|
|
+ public function testSubqueryInJoin()
|
|
|
{
|
|
|
$subquery = (new Query($this->connection))->select('*')->from('authors');
|
|
|
|
|
|
@@ -2129,7 +2129,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query->execute();
|
|
|
$this->assertCount(3, $result);
|
|
|
|
|
|
- $query->join(['b' => ['table' => $subquery, 'conditions' => ['b.id = articles.id']]], [], true);
|
|
|
+ $query->join(['b' => ['table' => $subquery, 'conditions' => [$query->newExpr()->equalFields('b.id', 'articles.id')]]], [], true);
|
|
|
$result = $query->execute();
|
|
|
$this->assertCount(1, $result);
|
|
|
}
|
|
|
@@ -2437,7 +2437,7 @@ class QueryTest extends TestCase
|
|
|
{
|
|
|
$query = new Query($this->connection);
|
|
|
|
|
|
- $expr = $query->newExpr('title = author_id');
|
|
|
+ $expr = $query->newExpr()->equalFields('title', 'author_id');
|
|
|
|
|
|
$query->update('articles')
|
|
|
->set($expr)
|
|
|
@@ -2445,7 +2445,7 @@ class QueryTest extends TestCase
|
|
|
$result = $query->sql();
|
|
|
|
|
|
$this->assertQuotedQuery(
|
|
|
- 'UPDATE <articles> SET title = author_id WHERE <id> = :',
|
|
|
+ 'UPDATE <articles> SET <title> = \(<author_id>\) WHERE <id> = :',
|
|
|
$result,
|
|
|
!$this->autoQuote
|
|
|
);
|
|
|
@@ -2623,7 +2623,7 @@ class QueryTest extends TestCase
|
|
|
'published' => 'N',
|
|
|
]
|
|
|
];
|
|
|
- $this->assertTable('articles', 1, $expected, ['id >= 4']);
|
|
|
+ $this->assertTable('articles', 1, $expected, ['id >=' => 4]);
|
|
|
}
|
|
|
|
|
|
/**
|