Skip to content

Commit

Permalink
Fixing failing tests in DboMysql and DboPostgres related to localized…
Browse files Browse the repository at this point in the history
… floats. Refs #1029
  • Loading branch information
markstory committed Aug 21, 2010
1 parent eb96d8a commit 12d4b52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 9 additions & 6 deletions cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -658,16 +658,19 @@ function value($data, $column = null, $safe = false) {
if ($data === '') {
return 'NULL';
}
if ((is_int($data) || is_float($data) || $data === '0') || (
if (is_float($data)) {
return sprintf('%F', $data);
}
if ((is_int($data) || $data === '0') || (
is_numeric($data) && strpos($data, ',') === false &&
$data[0] != '0' && strpos($data, 'e') === false)) {
return $data;
}
$data[0] != '0' && strpos($data, 'e') === false)
) {
return $data;
}
default:
$data = "'" . mysql_real_escape_string($data, $this->connection) . "'";
return "'" . mysql_real_escape_string($data, $this->connection) . "'";
break;
}
return $data;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion cake/libs/model/datasources/dbo/dbo_postgres.php
Expand Up @@ -299,8 +299,11 @@ function value($data, $column = null, $read = true) {
}

switch($column) {
case 'inet':
case 'float':
if (is_float($data)) {
$data = sprintf('%F', $data);
}
case 'inet':
case 'integer':
case 'date':
case 'datetime':
Expand Down

0 comments on commit 12d4b52

Please sign in to comment.