Bug 1423732 - Make Sqlite.jsm return an integer for getSchemaVersion. r=mak
authorJoshua Mengel, Bailey Hudson <17039@cgs.act.edu.au>
Tue, 23 Jan 2018 23:16:32 -0800
changeset 453163 b19b1b50594e7e9d075e9dcb27bc88fe25850c95
parent 453162 8f3552d6162728fffd709a25d8600acb06a69427
child 453164 f143545246a91f20b477edcf3288dfdc1e2daec7
push id8799
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 16:46:23 +0000
treeherdermozilla-beta@15334014dc67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1423732
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1423732 - Make Sqlite.jsm return an integer for getSchemaVersion. r=mak MozReview-Commit-ID: KLJ7W3ZnmJU
toolkit/modules/Sqlite.jsm
toolkit/modules/tests/xpcshell/test_sqlite.js
--- a/toolkit/modules/Sqlite.jsm
+++ b/toolkit/modules/Sqlite.jsm
@@ -1174,17 +1174,17 @@ OpenedConnection.prototype = Object.free
    * @return Promise<int>
    */
   getSchemaVersion(schemaName = "main") {
     return this.execute(`PRAGMA ${schemaName}.user_version`).then(
       function onSuccess(result) {
         if (result == null) {
           return 0;
         }
-        return JSON.stringify(result[0].getInt32(0));
+        return result[0].getInt32(0);
       }
     );
   },
 
   setSchemaVersion(value, schemaName = "main") {
     if (!Number.isInteger(value)) {
       // Guarding against accidental SQLi
       throw new TypeError("Schema version must be an integer. Got " + value);
--- a/toolkit/modules/tests/xpcshell/test_sqlite.js
+++ b/toolkit/modules/tests/xpcshell/test_sqlite.js
@@ -122,37 +122,37 @@ add_task(async function test_get_dummy_d
   Assert.equal(typeof(db), "object");
   await db.close();
 });
 
 add_task(async function test_schema_version() {
   let db = await getDummyDatabase("schema_version");
 
   let version = await db.getSchemaVersion();
-  Assert.equal(version, 0);
+  Assert.strictEqual(version, 0);
 
   db.setSchemaVersion(14);
   version = await db.getSchemaVersion();
-  Assert.equal(version, 14);
+  Assert.strictEqual(version, 14);
 
   for (let v of [0.5, "foobar", NaN]) {
     let success;
     try {
       await db.setSchemaVersion(v);
       info("Schema version " + v + " should have been rejected");
       success = false;
     } catch (ex) {
       if (!ex.message.startsWith("Schema version must be an integer."))
         throw ex;
       success = true;
     }
     Assert.ok(success);
 
     version = await db.getSchemaVersion();
-    Assert.equal(version, 14);
+    Assert.strictEqual(version, 14);
   }
 
   await db.execute("ATTACH :memory AS attached");
 
   let attachedVersion = await db.getSchemaVersion("attached");
   Assert.equal(attachedVersion, 0,
     "Should return 0 for initial attached schema version");