diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-03-07 07:53:15 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-03-07 07:53:15 +0000 |
commit | c5c033dc059b1c293779ff224023d51edb26dead (patch) | |
tree | 32c344327a8d8d453618d4cf8c7ecc6a17018e79 /includes/database/sqlite | |
parent | e43781c9555e712b0bb5adf4d49daea76f598e97 (diff) | |
download | brdo-c5c033dc059b1c293779ff224023d51edb26dead.tar.gz brdo-c5c033dc059b1c293779ff224023d51edb26dead.tar.bz2 |
#728730 by Damien Tournoud: Fixed Precision loss in DatabaseStatement_sqlite()::getStatement().
Diffstat (limited to 'includes/database/sqlite')
-rw-r--r-- | includes/database/sqlite/database.inc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc index 5889fafe7..dbfb4ef95 100644 --- a/includes/database/sqlite/database.inc +++ b/includes/database/sqlite/database.inc @@ -216,7 +216,12 @@ class DatabaseStatement_sqlite extends DatabaseStatementPrefetch implements Iter $count = 0; $new_args = array(); foreach ($args as $value) { - if (is_numeric($value)) { + if (is_float($value) || is_int($value)) { + if (is_float($value)) { + // Force the conversion to float so as not to loose precision + // in the automatic cast. + $value = sprintf('%F', $value); + } $query = substr_replace($query, $value, strpos($query, '?'), 1); } else { @@ -231,7 +236,13 @@ class DatabaseStatement_sqlite extends DatabaseStatementPrefetch implements Iter // Else, this is using named placeholders. foreach ($args as $placeholder => $value) { if (is_float($value) || is_int($value)) { - // We will remove this placeholder from the query and PDO throws an + if (is_float($value)) { + // Force the conversion to float so as not to loose precision + // in the automatic cast. + $value = sprintf('%F', $value); + } + + // We will remove this placeholder from the query as PDO throws an // exception if the number of placeholders in the query and the // arguments does not match. unset($args[$placeholder]); |