Skip to content

Commit

Permalink
Don't marshal arrays to 1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 15, 2018
1 parent 399624a commit 432ed3b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Database/Type/DecimalType.php
Expand Up @@ -157,8 +157,8 @@ public function marshal($value)
if (is_numeric($value)) {
return (float)$value;
}
if (is_array($value)) {
return 1;
if (!is_scalar($value)) {
return null;
}

return $value;
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Type/FloatType.php
Expand Up @@ -146,8 +146,8 @@ public function marshal($value)
if (is_string($value) && $this->_useLocaleParser) {
return $this->_parseValue($value);
}
if (is_array($value)) {
return 1.0;
if (!is_scalar($value)) {
return null;
}

return $value;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Type/DecimalTypeTest.php
Expand Up @@ -171,7 +171,7 @@ public function testMarshal()
$this->assertSame('3.5 bears', $result);

$result = $this->type->marshal(['3', '4']);
$this->assertSame(1, $result);
$this->assertNull($result);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Type/FloatTypeTest.php
Expand Up @@ -160,7 +160,7 @@ public function testMarshal()
$this->assertSame('3.5 bears', $result);

$result = $this->type->marshal(['3', '4']);
$this->assertSame(1.0, $result);
$this->assertNull($result);
}

/**
Expand Down

0 comments on commit 432ed3b

Please sign in to comment.