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 400596 b19b1b50594e
parent 400595 8f3552d61627
child 400597 f143545246a9
push id99193
push usermozilla@noorenberghe.ca
push dateWed, 24 Jan 2018 17:27:06 +0000
treeherdermozilla-inbound@b19b1b50594e [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");