Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"require": {
"php": "8.1 - 8.4",
"yiisoft/data": "dev-master",
"yiisoft/db": "^1.3"
"yiisoft/db": "dev-master"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.7.1",
Expand All @@ -43,11 +43,11 @@
"vimeo/psalm": "^5.26.1 || ^6.9.1",
"vlucas/phpdotenv": "^5.6.1",
"yiisoft/cache": "^3.0",
"yiisoft/db-mssql": "^1.2",
"yiisoft/db-mysql": "^1.2",
"yiisoft/db-oracle": "^1.3",
"yiisoft/db-pgsql": "^1.3",
"yiisoft/db-sqlite": "^1.2"
"yiisoft/db-mssql": "dev-master",
"yiisoft/db-mysql": "dev-master",
"yiisoft/db-oracle": "dev-master",
"yiisoft/db-pgsql": "dev-master",
"yiisoft/db-sqlite": "dev-master"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 18 additions & 1 deletion src/FilterHandler/LikeFilterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace Yiisoft\Data\Db\FilterHandler;

use Yiisoft\Data\Reader\Filter\Like;
use Yiisoft\Data\Reader\Filter\LikeMode as DataLikeMode;
use Yiisoft\Data\Reader\FilterInterface;
use Yiisoft\Db\QueryBuilder\Condition\LikeMode as DbLikeMode;

final class LikeFilterHandler implements QueryFilterHandlerInterface
{
Expand All @@ -18,6 +20,21 @@
{
/** @var Like $filter */

return new Criteria(['LIKE', $filter->field, $filter->value]);
return new Criteria([
'LIKE',
$filter->field,
$filter->value,
'caseSensitive' => $filter->caseSensitive,

Check warning on line 27 in src/FilterHandler/LikeFilterHandler.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "ArrayItem": @@ @@ public function getCriteria(FilterInterface $filter, Context $context): ?Criteria { /** @var Like $filter */ - return new Criteria(['LIKE', $filter->field, $filter->value, 'caseSensitive' => $filter->caseSensitive, 'mode' => $this->mapMode($filter->mode)]); + return new Criteria(['LIKE', $filter->field, $filter->value, 'caseSensitive' > $filter->caseSensitive, 'mode' => $this->mapMode($filter->mode)]); } public function mapMode(DataLikeMode $dataMode): DbLikeMode {
'mode' => $this->mapMode($filter->mode),
]);
}

public function mapMode(DataLikeMode $dataMode): DbLikeMode

Check warning on line 32 in src/FilterHandler/LikeFilterHandler.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "PublicVisibility": @@ @@ /** @var Like $filter */ return new Criteria(['LIKE', $filter->field, $filter->value, 'caseSensitive' => $filter->caseSensitive, 'mode' => $this->mapMode($filter->mode)]); } - public function mapMode(DataLikeMode $dataMode): DbLikeMode + protected function mapMode(DataLikeMode $dataMode): DbLikeMode { return match ($dataMode) { DataLikeMode::Contains => DbLikeMode::Contains,
{
return match ($dataMode) {
DataLikeMode::Contains => DbLikeMode::Contains,
DataLikeMode::StartsWith => DbLikeMode::StartsWith,
DataLikeMode::EndsWith => DbLikeMode::EndsWith,
};
}
}
2 changes: 1 addition & 1 deletion src/QueryDataReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
} elseif ($this->batchSize === null) {
yield from $this->read();
} else {
$iterator = $this->getPreparedQuery()->each($this->batchSize);
$iterator = $this->getPreparedQuery()->batch($this->batchSize);

/** @var array|object $row */
foreach ($iterator as $index => $row) {
Expand All @@ -82,7 +82,7 @@
if ($this->count === null) {
$q = $this->countParam ?? '*';

if ($q === '*' && is_array($this->data) && !$this->limit && !$this->offset) {

Check warning on line 85 in src/QueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "Identical": @@ @@ { if ($this->count === null) { $q = $this->countParam ?? '*'; - if ($q === '*' && is_array($this->data) && !$this->limit && !$this->offset) { + if ($q !== '*' && is_array($this->data) && !$this->limit && !$this->offset) { $this->count = count($this->data); } else { $query = $this->getPreparedQuery();
$this->count = count($this->data);
} else {
$query = $this->getPreparedQuery();
Expand Down
10 changes: 5 additions & 5 deletions tests/Base/BaseQueryDataReaderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,19 @@ public static function dataFilterSql(): array
],
'greater than or equal' => [
new GreaterThanOrEqual('column', 3.5),
'[[column]] >= \'3.5\'',
'[[column]] >= 3.5',
],
'less than' => [
new LessThan('column', 10.7),
'[[column]] < \'10.7\'',
'[[column]] < 10.7',
],
'less-than-or-equal' => [
new LessThanOrEqual('column', 100),
'[[column]] <= 100',
],
'in' => [
new In('column', [10, 20.5, 30]),
'[[column]] IN (10, \'20.5\', 30)',
'[[column]] IN (10, 20.5, 30)',
],
'like' => [
new Like('column', 'foo'),
Expand All @@ -245,11 +245,11 @@ public static function dataFilterSql(): array
],
'not greater than or equal' => [
new Not(new GreaterThanOrEqual('column', 3.5)),
'[[column]] < \'3.5\'',
'[[column]] < 3.5',
],
'not less than' => [
new Not(new LessThan('column', 10.7)),
'[[column]] >= \'10.7\'',
'[[column]] >= 10.7',
],
'not less than or equal' => [
new Not(new LessThanOrEqual('column', 100)),
Expand Down
7 changes: 2 additions & 5 deletions tests/Base/DataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Yiisoft\Data\Db\Tests\Base;

use DateTime;
use Yiisoft\Data\Db\QueryDataReader;
use Yiisoft\Data\Reader\DataReaderInterface;
use Yiisoft\Data\Tests\Common\FixtureTrait;
Expand All @@ -13,6 +12,8 @@
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Query\Query;

use function is_object;

trait DataTrait
{
use FixtureTrait;
Expand Down Expand Up @@ -60,10 +61,6 @@ protected function assertFixtures(array $expectedFixtureIndexes, array $actualFi
$fixture['number'] = (int) $fixture['number'];
$fixture['balance'] = (float) $fixture['balance'];

if ($fixture['born_at'] !== null && $this->getConnection()->getDriverName() === 'oci') {
$fixture['born_at'] = DateTime::createFromFormat('d-M-y', $fixture['born_at'])->format('Y-m-d');
}

$processedActualFixtures[$fixture['number'] - 1] = $fixture;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Sqlite/QueryDataReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static function dataOffset(): array
{
return [
[
'SELECT * FROM `customer` LIMIT 9223372036854775807 OFFSET 2',
'SELECT * FROM "customer" LIMIT 9223372036854775807 OFFSET 2',
],
];
}
Expand Down
14 changes: 7 additions & 7 deletions tests/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Schema\SchemaInterface;
use Yiisoft\Db\Schema\Column\ColumnBuilder;

final class TestHelper
{
Expand All @@ -19,12 +19,12 @@ public static function loadFixtures(ConnectionInterface $db): void
$db->createCommand()->createTable(
'customer',
[
'id' => $db->getSchema()->createColumn(SchemaInterface::TYPE_INTEGER)->notNull(),
'name' => $db->getSchema()->createColumn(SchemaInterface::TYPE_STRING, 128)->notNull(),
'email' => $db->getSchema()->createColumn(SchemaInterface::TYPE_STRING, 128),
'address' => $db->getSchema()->createColumn(SchemaInterface::TYPE_TEXT),
'status' => $db->getSchema()->createColumn(SchemaInterface::TYPE_INTEGER)->defaultValue(0),
'profile_id' => $db->getSchema()->createColumn(SchemaInterface::TYPE_INTEGER),
'id' => ColumnBuilder::integer()->notNull(),
'name' => ColumnBuilder::string(128)->notNull(),
'email' => ColumnBuilder::string(128),
'address' => ColumnBuilder::text(),
'status' => ColumnBuilder::integer()->defaultValue(0),
'profile_id' => ColumnBuilder::integer(),
]
)->execute();
$db->createCommand()->batchInsert(
Expand Down
Loading