Skip to content

Commit

Permalink
fix "bigint" to int php type typecasting
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed May 24, 2024
1 parent 74e1b74 commit 2f5f8e0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Persistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ protected function _typecastSaveField(Field $field, $value)
}

$res = Type::getType($field->type)->convertToDatabaseValue($value, $this->getDatabasePlatform());

if (is_resource($res) && get_resource_type($res) === 'stream') {
$res = stream_get_contents($res);
}
Expand Down Expand Up @@ -556,7 +557,10 @@ protected function _typecastLoadField(Field $field, $value)
}

$res = Type::getType($field->type)->convertToPHPValue($value, $this->getDatabasePlatform());
if (is_resource($res) && get_resource_type($res) === 'stream') {

if ($field->type === 'bigint' && $res === (string) (int) $res) { // once DBAL 3.x support is dropped, it should no longer be needed
$res = (int) $res;
} elseif (is_resource($res) && get_resource_type($res) === 'stream') {
$res = stream_get_contents($res);
}

Expand Down

0 comments on commit 2f5f8e0

Please sign in to comment.