Fix #20628: Fix @return annotations for lastInsertId methods in yii\db\mssql namespace

This commit is contained in:
Maksim Spirkov
2025-10-20 15:08:07 +03:00
committed by GitHub
parent 5681a98bbb
commit 9676e529eb
7 changed files with 8 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ Yii Framework 2 Change Log
- Bug #20619: Fix `@return` annotation for `yii\db\Query::prepare()` (mspirkov)
- Bug #20618: Fix `@var` annotation for `yii\web\Response::$acceptMimeType` (mspirkov)
- Bug #20617: Fix `@return` annotation for `DataColumn::getDataCellValue()` (mspirkov)
- Bug #20628: Fix `@return` annotations for `lastInsertId` methods in `yii\db\mssql` namespace (mspirkov)
- Bug #20630: Fix `@var` annotations for `yii\web\CompositeUrlRule::$rules` and `yii\web\GroupUrlRule::$rules` (mspirkov)

View File

@@ -19,7 +19,7 @@ class DBLibPDO extends \PDO
/**
* Returns value of the last inserted ID.
* @param string|null $name the sequence name. Defaults to null.
* @return int last inserted ID value.
* @return string|false last inserted ID value.
*/
#[\ReturnTypeWillChange]
public function lastInsertId($name = null)

View File

@@ -19,7 +19,7 @@ class PDO extends \PDO
/**
* Returns value of the last inserted ID.
* @param string|null $sequence the sequence name. Defaults to null.
* @return int last inserted ID value.
* @return string|false last inserted ID value.
*/
#[\ReturnTypeWillChange]
public function lastInsertId($sequence = null)

View File

@@ -24,7 +24,7 @@ class SqlsrvPDO extends \PDO
* But when parameter is not specified it works as expected and returns actual
* last inserted ID (like the other PDO drivers).
* @param string|null $sequence the sequence name. Defaults to null.
* @return int last inserted ID value.
* @return string|false last inserted ID value.
*/
#[\ReturnTypeWillChange]
public function lastInsertId($sequence = null)

View File

@@ -1267,7 +1267,7 @@ SQL;
$sql = 'INSERT INTO {{profile}}([[description]]) VALUES (\'non duplicate\')';
$command = $db->createCommand($sql);
$command->execute();
$this->assertEquals(3, $db->getSchema()->getLastInsertID());
$this->assertSame('3', $db->getSchema()->getLastInsertID());
}
public function testQueryCache(): void

View File

@@ -39,7 +39,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
$sql = 'INSERT INTO {{profile}}([[description]]) VALUES (\'non duplicate\')';
$command = $db->createCommand($sql);
$command->execute();
$this->assertEquals(3, $db->getSchema()->getLastInsertID('profile_SEQ'));
$this->assertSame('3', $db->getSchema()->getLastInsertID('profile_SEQ'));
}
public function batchInsertSqlProvider()

View File

@@ -72,12 +72,12 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
$sql = 'INSERT INTO {{profile}}([[description]]) VALUES (\'non duplicate\')';
$command = $db->createCommand($sql);
$command->execute();
$this->assertEquals(3, $db->getSchema()->getLastInsertID('public.profile_id_seq'));
$this->assertSame('3', $db->getSchema()->getLastInsertID('public.profile_id_seq'));
$sql = 'INSERT INTO {{schema1.profile}}([[description]]) VALUES (\'non duplicate\')';
$command = $db->createCommand($sql);
$command->execute();
$this->assertEquals(3, $db->getSchema()->getLastInsertID('schema1.profile_id_seq'));
$this->assertSame('3', $db->getSchema()->getLastInsertID('schema1.profile_id_seq'));
}
public function dataProviderGetRawSql()