Skip to content

Rename getLastInsertID() method in ConnectionInterface to getLastInsertId() #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
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
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getColumnFactory(): ColumnFactoryInterface
* @throws InvalidCallException
* @throws Throwable
*/
public function getLastInsertID(?string $sequenceName = null): string
public function getLastInsertId(?string $sequenceName = null): string
{
if ($sequenceName === null) {
throw new InvalidArgumentException('Oracle not support lastInsertId without sequence name.');
Expand Down
4 changes: 2 additions & 2 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function testsInsertQueryAsColumnValue(): void
$command->delete('{{order_with_null_fk}}')->execute();
$command->insert('{{order}}', ['customer_id' => 1, 'created_at' => $time, 'total' => 42])->execute();
$columnValueQuery = new Query($db);
$orderId = $db->getLastInsertID('order_SEQ');
$orderId = $db->getLastInsertId('order_SEQ');
$columnValueQuery->select('created_at')->from('{{order}}')->where(['id' => $orderId]);
$command->insert(
'{{order_with_null_fk}}',
Expand Down Expand Up @@ -558,7 +558,7 @@ public function testNoTablenameReplacement(): void
],
)->execute();

$customerId = $db->getLastInsertID('customer_SEQ');
$customerId = $db->getLastInsertId('customer_SEQ');

$customer = $command->setSql(
<<<SQL
Expand Down
8 changes: 4 additions & 4 deletions tests/PdoConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testGetLastInsertID(): void
$command->insert('item', ['name' => 'Yii2 starter', 'category_id' => 1])->execute();
$command->insert('item', ['name' => 'Yii3 starter', 'category_id' => 1])->execute();

$this->assertSame('7', $db->getLastInsertID('item_SEQ'));
$this->assertSame('7', $db->getLastInsertId('item_SEQ'));

$db->close();
}
Expand All @@ -57,7 +57,7 @@ public function testGetLastInsertIDWithException(): void
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Oracle not support lastInsertId without sequence name.');

$db->getLastInsertID();
$db->getLastInsertId();
}

/**
Expand All @@ -77,8 +77,8 @@ public function testGetLastInsertIdWithTwoConnection()
$sql = 'INSERT INTO {{profile}}([[description]]) VALUES (\'non duplicate2\')';
$db2->createCommand($sql)->execute();

$this->assertNotEquals($db1->getLastInsertID('profile_SEQ'), $db2->getLastInsertID('profile_SEQ'));
$this->assertNotEquals($db2->getLastInsertID('profile_SEQ'), $db1->getLastInsertID('profile_SEQ'));
$this->assertNotEquals($db1->getLastInsertId('profile_SEQ'), $db2->getLastInsertId('profile_SEQ'));
$this->assertNotEquals($db2->getLastInsertId('profile_SEQ'), $db1->getLastInsertId('profile_SEQ'));

$db1->close();
$db2->close();
Expand Down
Loading