Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix BC issues
Browse files Browse the repository at this point in the history
Tigrov committed Nov 12, 2023
1 parent 826d6ea commit a148f0c
Showing 8 changed files with 22 additions and 28 deletions.
26 changes: 8 additions & 18 deletions .github/workflows/bc.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'
paths:
- 'src/**'
- '.github/workflows/bc.yml'
- 'composer.json'
push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'
paths:
- 'src/**'
- '.github/workflows/bc.yml'
- 'composer.json'

name: backwards compatibility

2 changes: 1 addition & 1 deletion src/Query/Query.php
Original file line number Diff line number Diff line change
@@ -662,7 +662,7 @@ public function where(array|string|ExpressionInterface|null $condition, array $p
return $this;
}

public function withQuery(QueryInterface|string $query, ExpressionInterface|string $alias, bool $recursive = false): static
public function withQuery(QueryInterface|string $query, string $alias, bool $recursive = false): static

Check warning on line 665 in src/Query/Query.php

Codecov / codecov/patch

src/Query/Query.php#L665

Added line #L665 was not covered by tests
{
$this->withQueries[] = ['query' => $query, 'alias' => $alias, 'recursive' => $recursive];
return $this;
5 changes: 2 additions & 3 deletions src/Query/QueryPartsInterface.php
Original file line number Diff line number Diff line change
@@ -645,11 +645,10 @@ public function where(array|string|ExpressionInterface|null $condition, array $p
* Prepends an SQL statement using `WITH` syntax.
*
* @param QueryInterface|string $query The SQL statement to append using `UNION`.
* @param ExpressionInterface|string $alias The query alias in `WITH` construction.
* To specify the alias in plain SQL, you may pass an instance of {@see ExpressionInterface}.
* @param string $alias The query alias in `WITH` construction.
* @param bool $recursive Its `true` if using `WITH RECURSIVE` and `false` if using `WITH`.
*/
public function withQuery(QueryInterface|string $query, ExpressionInterface|string $alias, bool $recursive = false): static;
public function withQuery(QueryInterface|string $query, string $alias, bool $recursive = false): static;

/**
* Specifies the `WITH` query clause for the query.
3 changes: 2 additions & 1 deletion src/QueryBuilder/AbstractDMLQueryBuilder.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

namespace Yiisoft\Db\QueryBuilder;

use Generator;
use JsonException;
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Constraint\IndexConstraint;
@@ -49,7 +50,7 @@ public function __construct(
) {
}

public function batchInsert(string $table, array $columns, iterable $rows, array &$params = []): string
public function batchInsert(string $table, array $columns, iterable|Generator $rows, array &$params = []): string
{
if (empty($rows)) {
return '';
3 changes: 2 additions & 1 deletion src/QueryBuilder/AbstractQueryBuilder.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

namespace Yiisoft\Db\QueryBuilder;

use Generator;
use Yiisoft\Db\Command\CommandInterface;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Query\QueryInterface;
@@ -108,7 +109,7 @@ public function alterColumn(string $table, string $column, ColumnInterface|strin
return $this->ddlBuilder->alterColumn($table, $column, $type);
}

public function batchInsert(string $table, array $columns, iterable $rows, array &$params = []): string
public function batchInsert(string $table, array $columns, iterable|Generator $rows, array &$params = []): string
{
return $this->dmlBuilder->batchInsert($table, $columns, $rows, $params);
}
5 changes: 3 additions & 2 deletions src/QueryBuilder/DMLQueryBuilderInterface.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

namespace Yiisoft\Db\QueryBuilder;

use Generator;
use JsonException;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
@@ -33,7 +34,7 @@ interface DMLQueryBuilderInterface
*
* @param string $table The table to insert new rows into.
* @param string[] $columns The column names of the table.
* @param iterable $rows The rows to batch-insert into the table.
* @param Generator|iterable $rows The rows to batch-insert into the table.
* @param array $params The binding parameters. This parameter exists.
*
* @throws Exception
@@ -48,7 +49,7 @@ interface DMLQueryBuilderInterface
* - That the values in each row must match the corresponding column names.
* - The method will escape the column names, and quote the values to insert.
*/
public function batchInsert(string $table, array $columns, iterable $rows, array &$params = []): string;
public function batchInsert(string $table, array $columns, iterable|Generator $rows, array &$params = []): string;

/**
* Creates a `DELETE` SQL statement.
3 changes: 2 additions & 1 deletion tests/AbstractQueryBuilderTest.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace Yiisoft\Db\Tests;

use Closure;
use Generator;
use JsonException;
use PHPUnit\Framework\TestCase;
use stdClass;
@@ -210,7 +211,7 @@ public function testAlterColumn(): void
*
* @psalm-param array<array-key, string> $columns
*/
public function testBatchInsert(string $table, array $columns, iterable $rows, string $expected): void
public function testBatchInsert(string $table, array $columns, iterable|Generator $rows, string $expected): void
{
$db = $this->getConnection();
3 changes: 2 additions & 1 deletion tests/Db/QueryBuilder/QueryBuilderTest.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

namespace Yiisoft\Db\Tests\Db\QueryBuilder;

use Generator;
use JsonException;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
@@ -47,7 +48,7 @@ public function testAddDefaultValue(): void
/**
* @dataProvider \Yiisoft\Db\Tests\Provider\QueryBuilderProvider::batchInsert
*/
public function testBatchInsert(string $table, array $columns, iterable $rows, string $expected): void
public function testBatchInsert(string $table, array $columns, iterable|Generator $rows, string $expected): void
{
$db = $this->getConnection();

0 comments on commit a148f0c

Please sign in to comment.