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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ?? [];
Expand Down
2 changes: 1 addition & 1 deletion src/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down
14 changes: 7 additions & 7 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function testsInsertQueryAsColumnValue(): void
$db->close();
}

public function testInsertWithReturningPksWithPrimaryKeyString(): void
public function testInsertReturningPksWithPrimaryKeyString(): void
{
$db = $this->getConnection();

Expand All @@ -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();

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down