Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REAL number with double-precision truncated/rounded (iOS version) #199

Closed
brodycj opened this issue Mar 6, 2015 · 2 comments
Closed

REAL number with double-precision truncated/rounded (iOS version) #199

brodycj opened this issue Mar 6, 2015 · 2 comments

Comments

@brodycj
Copy link
Contributor

brodycj commented Mar 6, 2015

As reported in the forum: https://groups.google.com/d/msg/cordova-sqliteplugin/01Zzh2m-iiQ/dpxj7vF6ZVIJ

Reproduced by the following test:

        test(suiteName + "Double precision decimal number insertion", function() {
          stop();
          var db = openDatabase("Double-precision-number-insertion.db", "1.0", "Demo", DEFAULT_SIZE);
          db.transaction(function(tx) {
            tx.executeSql('DROP TABLE IF EXISTS tt');
            tx.executeSql('CREATE TABLE IF NOT EXISTS tt (tr REAL)');
          }, function(err) { ok(false, err.message) }, function() {
            db.transaction(function(tx) {
              tx.executeSql("insert into tt (tr) VALUES (?)", [123456.789], function(tx, res) {
                equal(res.rowsAffected, 1, "row inserted");
                tx.executeSql("select * from tt", [], function(tx, res) {
                  start();
                  var row = res.rows.item(0);
                  strictEqual(row.tr, 123456.789, "Decimal number inserted properly");
                });
              });
            });
          });
        });

The double-precision decimal number is working OK in the Android & WP(8) versions.

@brodycj
Copy link
Contributor Author

brodycj commented Mar 6, 2015

The following change fixes the issue (and passes the other tests):

--- a/src/ios/SQLitePlugin.m
+++ b/src/ios/SQLitePlugin.m
@@ -410,7 +410,7 @@ static void sqlite_regexp(sqlite3_context* context, int argc, sqlite3_value** va
 #endif
                             break;
                         case SQLITE_FLOAT:
-                            columnValue = [NSNumber numberWithFloat: sqlite3_column_double(statement, i)];
+                            columnValue = [NSNumber numberWithDouble: sqlite3_column_double(statement, i)];
                             break;
                         case SQLITE_NULL:
                             columnValue = [NSNull null];

brodycj pushed a commit that referenced this issue Mar 6, 2015
…199)

Update test of big integer value bindings according to behavior of Web SQL vs. this plugin (ref: #195)
brodycj pushed a commit that referenced this issue Mar 10, 2015
Fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)

Testing ONLY:
- #147: testing with UNICODE line separator
- #195: Reproduce issue with double-precision REAL number on WP(8) ONLY
brodycj pushed a commit that referenced this issue Mar 10, 2015
Fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)

Testing ONLY:
- #147: testing with UNICODE line separator
- #195: Reproduce issue with double-precision REAL number on WP(8) ONLY
@brodycj
Copy link
Contributor Author

brodycj commented Mar 10, 2015

The fix has been tested and published.

@brodycj brodycj closed this as completed Mar 10, 2015
brodycj pushed a commit that referenced this issue Mar 10, 2015
Related to the following fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant