Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-3050

iOS: bug in typecasting of big integers from the database

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: Release 3.0.0
    • Fix Version/s: Release 4.0.0
    • Component/s: iOS
    • Labels:
    • Sprint:
      2014 Sprint 25 SDK

      Description

      I just discovered a bug in the database code, in that it does not properly typecast big integers coming from the database.

      Running this code:

      app.js

      var db = Titanium.Database.open('bigint_test');
      db.execute("DROP TABLE `test`")
      db.execute("CREATE TABLE `test` (`val1` BIGINT, `val2` BIGINT)");
      db.execute("DELETE FROM `test`");
      db.execute("INSERT INTO test (val1, val2) VALUES (1, 1296802544867)");
       
      Titanium.API.info(1296802544867);
      Titanium.API.info(db.execute("SELECT * FROM `test`").field(0));
      Titanium.API.info(db.execute("SELECT * FROM `test`").field(1));
       
      var table_info = db.execute("PRAGMA table_info(test)")
      for (var i=0; i < table_info.fieldCount(); i++) {
        Titanium.API.info(table_info.fieldName(i) + ": " + table_info.field(i));
      };
      

      produces this log:

      [INFO] 1296802544867
      [INFO] 1
      [INFO] -277578525
      [INFO] cid: 0
      [INFO] name: val1
      [INFO] type: BIGINT
      [INFO] notnull: 0
      [INFO] dflt_value: null
      [INFO] pk: 0
      

      So you can see that the last log line is wrong it should be 1296802544867.

      Looking at the .sql file from the iPhone Simulator, I can tell you that the right value is stored in the db, and that other sqlite clients give the right value back.

        Attachments

          Activity

            People

            • Assignee:
              ingo Ingo Muschenetz
              Reporter:
              mickstaugaard Mick Staugaard
            • Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • It looks like Backbone Issue Sync is not enabled for your project.

                  Git Source Code