Permalink
Browse files

Fixing failing tests in DboMysql and DboPostgres related to localized…

… floats. Refs #1029
  • Loading branch information...
1 parent eb96d8a commit 12d4b52f105e6c84824eb5c8e6ca6d4996760e4d @markstory markstory committed Aug 21, 2010
Showing with 13 additions and 7 deletions.
  1. +9 −6 cake/libs/model/datasources/dbo/dbo_mysql.php
  2. +4 −1 cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -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;
}
/**
@@ -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':

0 comments on commit 12d4b52

Please sign in to comment.