Skip to content

Commit

Permalink
Fix after update db package (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Nov 21, 2023
1 parent a9bfbf0 commit 3f5244c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
27 changes: 15 additions & 12 deletions src/MigrationBuilder.php
Expand Up @@ -9,7 +9,6 @@
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\Schema\Builder\ColumnInterface;
use Yiisoft\Db\Migration\Informer\MigrationInformerInterface;
Expand Down Expand Up @@ -91,13 +90,15 @@ public function insert(string $table, array $columns): void
*
* @param string $table The table that new rows will be inserted into.
* @param array $columns The column names.
* @param array $rows The rows to be batch inserted into the table
* @param iterable $rows The rows to be batch inserted into the table
*
* @psalm-param iterable<array-key, array<array-key, mixed>> $rows
*
* @throws Exception
* @throws InvalidConfigException
* @throws NotSupportedException
*/
public function batchInsert(string $table, array $columns, array $rows): void
public function batchInsert(string $table, array $columns, iterable $rows): void
{
$time = $this->beginCommand("Insert into $table");
$this->db->createCommand()->batchInsert($table, $columns, $rows)->execute();
Expand All @@ -111,20 +112,22 @@ public function batchInsert(string $table, array $columns, array $rows): void
* The method will properly escape the column names, and bind the values to be inserted.
*
* @param string $table The table that new rows will be inserted into/updated in.
* @param array|Query $insertColumns The column data (name => value) to be inserted into the table or instance
* of {@see Query} to perform `INSERT INTO ... SELECT` SQL statement.
* @param array|QueryInterface $insertColumns The column data (name => value) to insert into the table or an
* instance of {@see QueryInterface} to perform `INSERT INTO ... SELECT` SQL statement.
* @param array|bool $updateColumns The column data (name => value) to be updated if they already exist.
* If `true` is passed, the column data will be updated to match the insert column data.
* If `false` is passed, no update will be performed if the column data already exists.
* @param array $params The parameters to be bound to the command.
*
* @psalm-param array<string, mixed>|QueryInterface $insertColumns
*
* @throws Exception
* @throws InvalidConfigException
* @throws NotSupportedException
*/
public function upsert(
string $table,
array|Query $insertColumns,
array|QueryInterface $insertColumns,
array|bool $updateColumns = true,
array $params = []
): void {
Expand All @@ -140,8 +143,8 @@ public function upsert(
*
* @param string $table The table to be updated.
* @param array $columns The column data (name => value) to be updated.
* @param array|string $condition The conditions that will be put in the WHERE part. Please refer to
* {@see Query::where} on how to specify conditions.
* @param array|string $condition The condition to put in the `WHERE` part. Please refer to
* {@see QueryInterface::where()} on how to specify condition.
* @param array $params The parameters to be bound to the query.
*
* @throws Exception
Expand All @@ -159,8 +162,8 @@ public function update(string $table, array $columns, array|string $condition =
* Creates and executes a DELETE SQL statement.
*
* @param string $table The table where the data will be deleted from.
* @param array|string $condition The conditions that will be put in the WHERE part. Please refer to
* {@see Query::where} on how to specify conditions.
* @param array|string $condition The condition to put in the `WHERE` part. Please refer to
* {@see QueryInterface::where()} on how to specify condition.
* @param array $params The parameters to be bound to the query.
*
* @throws Exception
Expand Down Expand Up @@ -503,8 +506,8 @@ public function createIndex(
* Builds and executes a SQL statement for creating a view.
*
* @param string $viewName The name of the view to create.
* @param QueryInterface|string $subQuery The select statement which defines the view.
* This can be either a string or a {@see Query} object.
* @param QueryInterface|string $subQuery The select statement which defines the view. This can be either a string
* or a {@see QueryInterface}.
*
* @throws InvalidConfigException
* @throws NotSupportedException If this isn't supported by the underlying DBMS.
Expand Down
8 changes: 1 addition & 7 deletions tests/Common/Command/AbstractUpdateCommandTest.php
Expand Up @@ -200,13 +200,7 @@ public function testExecuteExtended(): void

/** Check table student field dateofbirth */
$this->assertSame('dateofbirth', $studentSchema->getColumn('dateofbirth')->getName());

if ($db->getDriverName() !== 'oci') {
$this->assertSame('date', $studentSchema->getColumn('dateofbirth')->getType());
} else {
$this->assertSame('string', $studentSchema->getColumn('dateofbirth')->getType());
}

$this->assertSame('date', $studentSchema->getColumn('dateofbirth')->getType());
$this->asserttrue($studentSchema->getColumn('dateofbirth')->isAllowNull());
}

Expand Down

0 comments on commit 3f5244c

Please sign in to comment.