Browse Source

Updated SqliteQueryBuilderTest to work with Composite in conditions

Updated code style, CHANGELOG
tags/2.0.8
SilverFire - Dmitry Naumenko 9 years ago
parent
commit
e2e4f76229
  1. 2
      framework/CHANGELOG.md
  2. 5
      framework/UPGRADE.md
  3. 6
      framework/db/QueryBuilder.php
  4. 8
      tests/framework/db/QueryBuilderTest.php
  5. 20
      tests/framework/db/sqlite/SqliteQueryBuilderTest.php

2
framework/CHANGELOG.md

@ -82,7 +82,7 @@ Yii Framework 2 Change Log
- Eng #10976: `Inflector::transliterate()` now uses `strtr` instead of `str_replace` (DrDeath72)
- Enh #11110: Added migrations for DB session (mdmunir)
- Enh #10941: Added `yii\helpers\ArrayHelper::isTraversable`, added support for traversable selections for dropdownList, radioList and checkboxList in `yii\helpers\Html`.
- Enh #10954: Query builder now supports `Traversable` objects for use in `in` conditions. (sammousa)
- Enh #10954: `yii\db\QueryBuilder` now accepts `\Traversable` objects for `in` condition (SamMousa, silverfire)
- Chg: HTMLPurifier dependency updated to `~4.6` (samdark)
- Chg #9854: Added `ActiveRecordInterface::populateRelation()` to respect the methods called by the implementation (SamMousa)
- Chg #10726: Added `yii\rbac\ManagerInterface::canAddChild()` (dkhlystov, samdark)

5
framework/UPGRADE.md

@ -19,16 +19,21 @@ ______________________
* The signature of `yii\helpers\BaseArrayHelper::index()` was changed. The method has got an extra optional parameter
`$groups`.
* `yii\helpers\BaseArrayHelper` methods `isIn()` and `isSubset()` throw `\yii\base\InvalidParamException`
instead of `\InvalidArgumentException`. If you wrap calls of these methods in try/catch block, change expected
exception class.
* `yii\rbac\ManagerInterface::canAddChild()` method was added. If you have custom backend for RBAC you need to implement
it.
* The signature of `yii\web\User::loginRequired()` was changed. The method has got an extra optional parameter
`$checkAcceptHeader`.
* The signature of `yii\db\ColumnSchemaBuilder::__construct()` was changed. The method has got an extra optional
parameter `$db`. In case you are instantiating this class yourself and using the `$config` parameter, you will need to
move it to the right by one.
* String types in the MSSQL column schema map were upgraded to Unicode storage types. This will have no effect on
existing columns, but any new columns you generate via the migrations engine will now store data as Unicode.

6
framework/db/QueryBuilder.php

@ -1174,7 +1174,7 @@ class QueryBuilder extends \yii\base\Object
return $this->buildSubqueryInCondition($operator, $column, $values, $params);
}
if ($column instanceof \Traversable || count($column) > 1) {
if ($column instanceof \Traversable || count($column) > 1) {
return $this->buildCompositeInCondition($operator, $column, $values, $params);
}
@ -1248,7 +1248,7 @@ class QueryBuilder extends \yii\base\Object
* Builds SQL for IN condition
*
* @param string $operator
* @param array $columns
* @param array|\Traversable $columns
* @param array $values
* @param array $params
* @return string SQL
@ -1403,7 +1403,7 @@ class QueryBuilder extends \yii\base\Object
return "$column $operator $phName";
}
}
/**
* Creates a SELECT EXISTS() SQL statement.
* @param string $rawSql the subquery in a raw form to select from.

8
tests/framework/db/QueryBuilderTest.php

@ -1026,8 +1026,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
[ ['in', 'id', [1]], '[[id]]=:qp0', [':qp0' => 1] ],
[ ['in', 'id', new TraversableObject([1])], '[[id]]=:qp0', [':qp0' => 1] ],
// composite in
[
'composite in' => [
['in', ['id', 'name'], [['id' =>1, 'name' => 'oy']]],
'([[id]], [[name]]) IN ((:qp0, :qp1))',
[':qp0' => 1, ':qp1' => 'oy']
@ -1038,13 +1037,12 @@ abstract class QueryBuilderTest extends DatabaseTestCase
[ ['in', 'id', new TraversableObject([1, 2, 3])], '[[id]] IN (:qp0, :qp1, :qp2)', [':qp0' => 1, ':qp1' => 2, ':qp2' => 3] ],
// composite in using array objects.
[
'composite in using array objects' => [
['in', new TraversableObject(['id', 'name']), new TraversableObject([
['id' => 1, 'name' => 'oy'],
['id' => 2, 'name' => 'yo'],
])],
'([[id]], [[name]]) IN ((:qp0, :qp1))',
'([[id]], [[name]]) IN ((:qp0, :qp1), (:qp2, :qp3))',
[':qp0' => 1, ':qp1' => 'oy', ':qp2' => 2, ':qp3' => 'yo']
],
// exists

20
tests/framework/db/sqlite/SqliteQueryBuilderTest.php

@ -4,6 +4,7 @@ namespace yiiunit\framework\db\sqlite;
use yii\db\Query;
use yii\db\Schema;
use yii\test\TraversableObject;
use yiiunit\framework\db\QueryBuilderTest;
/**
@ -25,6 +26,25 @@ class SqliteQueryBuilderTest extends QueryBuilderTest
]);
}
public function conditionProvider()
{
return array_merge(parent::conditionProvider(), [
'composite in using array objects' => [
['in', new TraversableObject(['id', 'name']), new TraversableObject([
['id' => 1, 'name' => 'oy'],
['id' => 2, 'name' => 'yo'],
])],
'(([[id]] = :qp0 AND [[name]] = :qp1) OR ([[id]] = :qp2 AND [[name]] = :qp3))',
[':qp0' => 1, ':qp1' => 'oy', ':qp2' => 2, ':qp3' => 'yo']
],
'composite in' => [
['in', ['id', 'name'], [['id' =>1, 'name' => 'oy']]],
'(([[id]] = :qp0 AND [[name]] = :qp1))',
[':qp0' => 1, ':qp1' => 'oy']
],
]);
}
public function testAddDropPrimaryKey()
{
$this->markTestSkipped('Comments are not supported in SQLite');

Loading…
Cancel
Save