Merge pull request #8874 from johannesx75/fix-pdoconnector-generatedid-type-2

Fix PDOConnector GeneratedID return type
This commit is contained in:
Loz Calver 2019-03-22 09:09:23 +00:00 committed by GitHub
commit 8483a9644c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -483,7 +483,7 @@ class PDOConnector extends DBConnector implements TransactionManager
public function getGeneratedID($table)
{
return $this->pdoConnection->lastInsertId();
return (int) $this->pdoConnection->lastInsertId();
}
public function affectedRows()

View File

@ -1925,6 +1925,17 @@ class DataObjectTest extends SapphireTest
$this->assertEquals('1988-03-04 06:30:00', $obj->DatetimeField);
}
/**
* Tests that the autogenerated ID is returned as int
*/
public function testIDFieldTypeAfterInsert()
{
$obj = new DataObjectTest\Fixture();
$obj->write();
$this->assertInternalType("int", $obj->ID);
}
public function testTwoSubclassesWithTheSameFieldNameWork()
{
// Create two objects of different subclasses, setting the values of fields that are