diff --git a/CHANGELOG.md b/CHANGELOG.md index e2562575..a90cef55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - Enh #324: Refactor `Command::insertWithReturningPks()` method (@Tigrov) - Enh #325: Refactor `DMLQueryBuilder::upsert()` method (@Tigrov) - Chg #326: Add alias in `DQLQueryBuilder::selectExists()` method for consistency with other DBMS (@Tigrov) +- Chg #330: Rename `insertWithReturningPks()` to `insertReturningPks()` in `Command` and `DMLQueryBuilder` classes (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/src/Command.php b/src/Command.php index 837be551..df637519 100644 --- a/src/Command.php +++ b/src/Command.php @@ -24,7 +24,7 @@ */ final class Command extends AbstractPdoCommand { - public function insertWithReturningPks(string $table, array|QueryInterface $columns): array|false + public function insertReturningPks(string $table, array|QueryInterface $columns): array|false { $tableSchema = $this->db->getSchema()->getTableSchema($table); $returnColumns = $tableSchema?->getPrimaryKey() ?? []; diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index ef1cd778..cd59e96c 100644 --- a/src/DMLQueryBuilder.php +++ b/src/DMLQueryBuilder.php @@ -49,7 +49,7 @@ public function insertBatch(string $table, iterable $rows, array $columns = [], return $query . "\nSELECT " . implode(" FROM DUAL UNION ALL\nSELECT ", $values) . ' FROM DUAL'; } - public function insertWithReturningPks(string $table, array|QueryInterface $columns, array &$params = []): string + public function insertReturningPks(string $table, array|QueryInterface $columns, array &$params = []): string { throw new NotSupportedException(__METHOD__ . ' is not supported by Oracle.'); } diff --git a/tests/CommandTest.php b/tests/CommandTest.php index f841eb18..c80937a7 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -352,7 +352,7 @@ public function testsInsertQueryAsColumnValue(): void $db->close(); } - public function testInsertWithReturningPksWithPrimaryKeyString(): void + public function testInsertReturningPksWithPrimaryKeyString(): void { $db = $this->getConnection(); @@ -368,14 +368,14 @@ public function testInsertWithReturningPksWithPrimaryKeyString(): void ['id' => 'varchar(10) primary key', 'name' => 'varchar(10)'], )->execute(); - $result = $command->insertWithReturningPks('{{test_insert_pk}}', ['id' => '1', 'name' => 'test']); + $result = $command->insertReturningPks('{{test_insert_pk}}', ['id' => '1', 'name' => 'test']); $this->assertSame(['id' => '1'], $result); $db->close(); } - public function testInsertWithReturningPksWithPrimaryKeySignedDecimal(): void + public function testInsertReturningPksWithPrimaryKeySignedDecimal(): void { $db = $this->getConnection(); @@ -391,19 +391,19 @@ public function testInsertWithReturningPksWithPrimaryKeySignedDecimal(): void ['id' => 'number(5,2) primary key', 'name' => 'varchar(10)'], )->execute(); - $result = $command->insertWithReturningPks('{{test_insert_pk}}', ['id' => '-123.45', 'name' => 'test']); + $result = $command->insertReturningPks('{{test_insert_pk}}', ['id' => '-123.45', 'name' => 'test']); $this->assertSame(['id' => '-123.45'], $result); $db->close(); } - public function testInsertWithReturningPksWithQuery(): void + public function testInsertReturningPksWithQuery(): void { $this->expectException(NotSupportedException::class); - $this->expectExceptionMessage('Yiisoft\Db\Oracle\Command::insertWithReturningPks() is not supported by Oracle when inserting sub-query.'); + $this->expectExceptionMessage('Yiisoft\Db\Oracle\Command::insertReturningPks() is not supported by Oracle when inserting sub-query.'); - parent::testInsertWithReturningPksWithQuery(); + parent::testInsertReturningPksWithQuery(); } public function testInsertSelectAlias(): void diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index 169202e2..26cde44f 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -320,8 +320,8 @@ public function testInsert( parent::testInsert($table, $columns, $params, $expectedSQL, $expectedParams); } - #[DataProviderExternal(QueryBuilderProvider::class, 'insertWithReturningPks')] - public function testInsertWithReturningPks( + #[DataProviderExternal(QueryBuilderProvider::class, 'insertReturningPks')] + public function testInsertReturningPks( string $table, array|QueryInterface $columns, array $params, @@ -330,12 +330,12 @@ public function testInsertWithReturningPks( ): void { $this->expectException(NotSupportedException::class); $this->expectExceptionMessage( - 'Yiisoft\Db\Oracle\DMLQueryBuilder::insertWithReturningPks is not supported by Oracle.', + 'Yiisoft\Db\Oracle\DMLQueryBuilder::insertReturningPks is not supported by Oracle.', ); $db = $this->getConnection(true); $qb = $db->getQueryBuilder(); - $qb->insertWithReturningPks($table, $columns, $params); + $qb->insertReturningPks($table, $columns, $params); } public function testRenameTable(): void