Skip to content

Commit

Permalink
DboMssql::value() now returns NULL for numeric column types (float, i…
Browse files Browse the repository at this point in the history
…nteger, binary) when the column data is empty. Fixes #28.
  • Loading branch information
jperras committed Sep 6, 2009
1 parent bcbdb1c commit 2484179
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cake/libs/model/datasources/dbo/dbo_mssql.php
Expand Up @@ -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 "''";
}
Expand Down
12 changes: 12 additions & 0 deletions cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
Expand Up @@ -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
Expand Down

0 comments on commit 2484179

Please sign in to comment.