Skip to content

Commit 1e639a5

Browse files
authored
Rename insertWithReturningPks() to insertReturningPks() (#366)
1 parent 51ec454 commit 1e639a5

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
- Enh #361, #362: Refactor `DMLQueryBuilder::insertWithReturningPks()` method (@Tigrov)
4545
- New #361, #362: Implement `DMLQueryBuilder::upsertReturning()` method (@Tigrov)
4646
- Chg #363: Add alias in `DQLQueryBuilder::selectExists()` method for consistency with other DBMS (@Tigrov)
47+
- Chg #366: Rename `DMLQueryBuilder::insertWithReturningPks()` to `DMLQueryBuilder::insertReturningPks()` (@Tigrov)
4748

4849
## 1.2.0 March 21, 2024
4950

src/DMLQueryBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ final class DMLQueryBuilder extends AbstractDMLQueryBuilder
3030
* @throws InvalidConfigException
3131
* @throws NotSupportedException
3232
*/
33-
public function insertWithReturningPks(string $table, array|QueryInterface $columns, array &$params = []): string
33+
public function insertReturningPks(string $table, array|QueryInterface $columns, array &$params = []): string
3434
{
3535
$primaryKeys = $this->schema->getTableSchema($table)?->getPrimaryKey() ?? [];
3636

37-
return $this->insertWithReturning($table, $columns, $primaryKeys, $params);
37+
return $this->insertReturning($table, $columns, $primaryKeys, $params);
3838
}
3939

4040
/**
@@ -89,7 +89,7 @@ public function upsertReturning(
8989
[$uniqueNames] = $this->prepareUpsertColumns($table, $insertColumns, $updateColumns);
9090

9191
if (empty($uniqueNames)) {
92-
return $this->insertWithReturning($table, $insertColumns, $returnColumns, $params);
92+
return $this->insertReturning($table, $insertColumns, $returnColumns, $params);
9393
}
9494

9595
$tableSchema = $this->schema->getTableSchema($table);
@@ -115,7 +115,7 @@ public function upsertReturning(
115115
/**
116116
* @param string[] $returnColumns
117117
*/
118-
private function insertWithReturning(
118+
private function insertReturning(
119119
string $table,
120120
array|QueryInterface $columns,
121121
array|null $returnColumns = null,

tests/CommandTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testInsertVarbinary(mixed $expectedData, mixed $testData): void
9595
$this->assertSame($expectedData, $resultData['blob_col']);
9696
}
9797

98-
public function testInsertWithReturningPksWithComputedColumn(): void
98+
public function testInsertReturningPksWithComputedColumn(): void
9999
{
100100
$db = $this->getConnection(true);
101101

@@ -122,13 +122,13 @@ public function testInsertWithReturningPksWithComputedColumn(): void
122122
)->execute();
123123
$insertedString = 'test';
124124
$transaction = $db->beginTransaction();
125-
$result = $command->insertWithReturningPks('{{test_trigger}}', ['stringcol' => $insertedString]);
125+
$result = $command->insertReturningPks('{{test_trigger}}', ['stringcol' => $insertedString]);
126126
$transaction->commit();
127127

128128
$this->assertSame(['id' => '1'], $result);
129129
}
130130

131-
public function testInsertWithReturningPksWithRowVersionColumn(): void
131+
public function testInsertReturningPksWithRowVersionColumn(): void
132132
{
133133
$db = $this->getConnection(true);
134134

@@ -139,12 +139,12 @@ public function testInsertWithReturningPksWithRowVersionColumn(): void
139139
SQL
140140
)->execute();
141141
$insertedString = 'test';
142-
$result = $command->insertWithReturningPks('{{test_trigger}}', ['stringcol' => $insertedString]);
142+
$result = $command->insertReturningPks('{{test_trigger}}', ['stringcol' => $insertedString]);
143143

144144
$this->assertSame(['id' => '1'], $result);
145145
}
146146

147-
public function testInsertWithReturningPksWithRowVersionNullColumn(): void
147+
public function testInsertReturningPksWithRowVersionNullColumn(): void
148148
{
149149
$db = $this->getConnection(true);
150150

@@ -155,7 +155,7 @@ public function testInsertWithReturningPksWithRowVersionNullColumn(): void
155155
SQL
156156
)->execute();
157157
$insertedString = 'test';
158-
$result = $command->insertWithReturningPks(
158+
$result = $command->insertReturningPks(
159159
'{{test_trigger}}',
160160
['stringcol' => $insertedString, 'RV' => new Expression('DEFAULT')],
161161
);
@@ -168,10 +168,10 @@ public function testResetSequence(): void
168168
$db = $this->getConnection(true);
169169

170170
$command = $db->createCommand();
171-
$oldRow = $command->insertWithReturningPks('{{item}}', ['name' => 'insert_value_for_sequence', 'category_id' => 1]);
171+
$oldRow = $command->insertReturningPks('{{item}}', ['name' => 'insert_value_for_sequence', 'category_id' => 1]);
172172
$command->delete('{{item}}', ['id' => $oldRow['id']])->execute();
173173
$command->resetSequence('{{item}}')->execute();
174-
$newRow = $command->insertWithReturningPks('{{item}}', ['name' => 'insert_value_for_sequence', 'category_id' => 1]);
174+
$newRow = $command->insertReturningPks('{{item}}', ['name' => 'insert_value_for_sequence', 'category_id' => 1]);
175175

176176
$this->assertEquals($oldRow['id'], $newRow['id']);
177177
}

tests/Provider/QueryBuilderProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public static function batchInsert(): array
310310
return $values;
311311
}
312312

313-
public static function insertWithReturningPks(): array
313+
public static function insertReturningPks(): array
314314
{
315315
return [
316316
'regular-values' => [

tests/QueryBuilderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,15 @@ public function testBatchInsert(
364364
parent::testBatchInsert($table, $rows, $columns, $expected, $expectedParams);
365365
}
366366
367-
#[DataProviderExternal(QueryBuilderProvider::class, 'insertWithReturningPks')]
368-
public function testInsertWithReturningPks(
367+
#[DataProviderExternal(QueryBuilderProvider::class, 'insertReturningPks')]
368+
public function testInsertReturningPks(
369369
string $table,
370370
array|QueryInterface $columns,
371371
array $params,
372372
string $expectedSQL,
373373
array $expectedParams
374374
): void {
375-
parent::testInsertWithReturningPks($table, $columns, $params, $expectedSQL, $expectedParams);
375+
parent::testInsertReturningPks($table, $columns, $params, $expectedSQL, $expectedParams);
376376
}
377377
378378
public function testRenameColumn(): void

0 commit comments

Comments
 (0)