From 9933f0f5616064c0f96190a77e3b314a43b93f6e Mon Sep 17 00:00:00 2001 From: "sdwilsh@shawnwilsher.com" Date: Tue, 3 Jul 2007 09:56:20 -0700 Subject: [PATCH] Bug 386371 - Use getters and setters for database schema version. r=myk --- .../contentprefs/src/nsContentPrefService.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/toolkit/components/contentprefs/src/nsContentPrefService.js b/toolkit/components/contentprefs/src/nsContentPrefService.js index 52f3749ab80..dcca93748c0 100755 --- a/toolkit/components/contentprefs/src/nsContentPrefService.js +++ b/toolkit/components/contentprefs/src/nsContentPrefService.js @@ -688,15 +688,7 @@ ContentPrefService.prototype = { dbConnection = dbService.openDatabase(dbFile); // Get the version of the database in the file. - var statement, version; - try { - statement = dbConnection.createStatement("PRAGMA user_version"); - statement.executeStep(); - version = statement.getInt32(0); - } - finally { - statement.reset(); - } + var version = dbConnection.schemaVersion; if (version != this._dbVersion) { this._log("database: v" + version + ", application: v" + @@ -732,7 +724,7 @@ ContentPrefService.prototype = { var dbConnection = aDBService.openDatabase(aDBFile); for (var table in this._dbSchema) dbConnection.createTable(table, this._dbSchema[table]); - dbConnection.executeSimpleSQL("PRAGMA user_version = " + this._dbVersion); + dbConnection.schemaVersion = this._dbVersion; return dbConnection; }, @@ -784,7 +776,7 @@ ContentPrefService.prototype = { aDBConnection.executeSimpleSQL("DROP TABLE keys"); aDBConnection.executeSimpleSQL("DROP TABLE sites"); - aDBConnection.executeSimpleSQL("PRAGMA user_version = " + this._dbVersion); + aDBConnection.schemaVersion = this._dbVersion; }, _dbMigrate1To2: function ContentPrefService___dbMigrate1To2(aDBConnection) { @@ -800,7 +792,7 @@ ContentPrefService.prototype = { aDBConnection.executeSimpleSQL("DROP TABLE groupers"); aDBConnection.executeSimpleSQL("DROP TABLE groupsOld"); - aDBConnection.executeSimpleSQL("PRAGMA user_version = " + this._dbVersion); + aDBConnection.schemaVersion = this._dbVersion; },