Closed bikalbasnet closed 5 years ago
Steps to Reproduce Let's say we have an entity whose primary key is integer.
... public static function fields() { return [ 'id' => ['type' => 'integer', 'autoincrement' => true, 'primary' => true], 'username' => ['type' => 'string', 'required' => true], ]; } ...
and now we create a new record for this entity
$entity = $mapper->create([ 'name' => 'Chester Tester', 'username' => 'chester' ]); var_dump($entity);
Expected Result The primary key should be integer 1 not string "1"
--- _data: array:14 [ "id" => 1 ....
Actual Result But we are getting primary key as string 1
--- _data: array:14 [ "id" => "1" ....
Investigation Upon some Investigation I found the following code on https://github.com/spotorm/spot2/blob/master/lib/Mapper.php#L769
$result = $connection->lastInsertId($sequenceName); $entity->$pkField = $result;
But after this function is called shouldn't we type cast the value into integer if the type of primary key is integer with something like this atleast?
$entity->$pkField = ($pkFieldInfo['type'] === "integer") ? (integer) $result : $result;
Steps to Reproduce Let's say we have an entity whose primary key is integer.
and now we create a new record for this entity
Expected Result The primary key should be integer 1 not string "1"
Actual Result But we are getting primary key as string 1
Investigation Upon some Investigation I found the following code on https://github.com/spotorm/spot2/blob/master/lib/Mapper.php#L769
But after this function is called shouldn't we type cast the value into integer if the type of primary key is integer with something like this atleast?