Skip to content
Browse files

DboMssql::value() now returns NULL for numeric column types (float, i…

…nteger, binary) when the column data is empty. Fixes #28.
  • Loading branch information...
1 parent bcbdb1c commit 2484179e3600485480e65ab18b5f37448610337a @jperras jperras committed
View
3 cake/libs/model/datasources/dbo/dbo_mssql.php
@@ -259,6 +259,9 @@ function value($data, $column = null, $safe = false) {
if ($data === null) {
return 'NULL';
}
+ if (in_array($column, array('integer', 'float', 'binary')) && $data === '') {
+ return 'NULL';
+ }
if ($data === '') {
return "''";
}
View
12 cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
@@ -345,6 +345,18 @@ function testQuoting() {
$expected = "'1,2'";
$result = $this->db->value('1,2', 'float');
$this->assertIdentical($expected, $result);
+
+ $expected = 'NULL';
+ $result = $this->db->value('', 'integer');
+ $this->assertIdentical($expected, $result);
+
+ $expected = 'NULL';
+ $result = $this->db->value('', 'float');
+ $this->assertIdentical($expected, $result);
+
+ $expected = 'NULL';
+ $result = $this->db->value('', 'binary');
+ $this->assertIdentical($expected, $result);
}
/**
* testFields method

0 comments on commit 2484179

Please sign in to comment.
Something went wrong with that request. Please try again.