diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 70367b9bc..5ac4013c8 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -672,7 +672,7 @@ class DboMysql extends DboMysqlBase { return 'NULL'; } if (is_float($data)) { - return sprintf('%F', $data); + return str_replace(',', '.', sprintf('%G', $data)); } if ((is_int($data) || $data === '0') || ( is_numeric($data) && strpos($data, ',') === false && diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index d94db8ed0..2cdc6ea73 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -239,14 +239,33 @@ class DboMysqlTest extends CakeTestCase { setlocale(LC_ALL, 'de_DE'); $result = $this->db->value(3.141593, 'float'); - $this->assertEqual((string)$result, '3.141593'); - + $this->assertTrue(strpos((string)$result, ',') === false); + $result = $this->db->value(3.141593); - $this->assertEqual((string)$result, '3.141593'); + $this->assertTrue(strpos((string)$result, ',') === false); + + $result = $this->db->value(2.2E-54, 'float'); + $this->assertEqual('2.2E-54', (string)$result); + + $result = $this->db->value(2.2E-54); + $this->assertEqual('2.2E-54', (string)$result); setlocale(LC_ALL, $restore); } +/** + * test that scientific notations are working correctly + * + * @return void + */ + function testScientificNotation() { + $result = $this->db->value(2.2E-54, 'float'); + $this->assertEqual('2.2E-54', (string)$result); + + $result = $this->db->value(2.2E-54); + $this->assertEqual('2.2E-54', (string)$result); + } + /** * testTinyintCasting method *