litehelpers / cordova-sqlite-evplus-ext-legacy-build-free

TODO INCORRECT PACKAGE NAME: Cordova sqlite storage plugin, premium enterprise legacy support (GPL or commercial license) for Android, iOS, and Windows
Other
10 stars 9 forks source link

Crash: Infinity values in SQLite [iOS] #4

Open brodycj opened 8 years ago

brodycj commented 8 years ago

As reported by @reconka in litehelpers/Cordova-sqlite-storage/issues/405:

I noticed the IOS application crash when I try to select rows which contains infinite number.

here is my simple test:

document.addEventListener("deviceready", onDeviceReady, false);
      function onDeviceReady() {
        var db = window.sqlitePlugin.openDatabase("Database", "1.0", "Demo", -1);

        db.transaction(function(tx) {
          tx.executeSql('DROP TABLE IF EXISTS test_table');
          tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id REAL)');

          tx.executeSql("INSERT INTO test_table (id) VALUES (?)", ['9e999'], function(tx, res) {
          console.log("insertId: " + res.insertId +  " -- probably 1"); // check #18/#38 is fixed
          alert("insertId: " + res.insertId  + " -- should be valid");

            db.transaction(function(tx) {
              tx.executeSql("SELECT id from test_table;", [], function(tx, res) {
                 alert("res.rows.length: " + res.rows.length  + " -- should be 1");
              });
            });

          }, function(e) {
            console.log("ERROR: " + e.message);
          });
        });
       }

And ERROR msg: \ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid number value (infinite) in JSON write'

Will be fixed in this version.