Closed Bug 386371 Opened 18 years ago Closed 18 years ago

Use getters and setters for database schema version

Categories

(Toolkit :: Preferences, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha8

People

(Reporter: sdwilsh, Assigned: sdwilsh)

References

Details

Attachments

(1 file)

Depends on: 386366
No longer depends on: 386184
Attached patch v1.0Splinter Review
not sure who is good to review this...
Assignee: nobody → sdwilsh
Status: NEW → ASSIGNED
Attachment #270556 - Flags: review?(myk)
Comment on attachment 270556 [details] [diff] [review] v1.0 >Index: toolkit/components/contentprefs/src/nsContentPrefService.js >=================================================================== >RCS file: /cvsroot/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js,v >retrieving revision 1.7 >diff -u -8 -p -r1.7 nsContentPrefService.js >--- toolkit/components/contentprefs/src/nsContentPrefService.js 26 Jun 2007 04:57:30 -0000 1.7 >+++ toolkit/components/contentprefs/src/nsContentPrefService.js 2 Jul 2007 08:48:36 -0000 >@@ -683,25 +683,17 @@ ContentPrefService.prototype = { > this._log("no database file; creating database"); > dbConnection = this._dbCreate(dbService, dbFile); > } > else { > try { > 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" + > this._dbVersion + "; migrating database"); > this._dbMigrate(dbConnection, version, this._dbVersion); > } Seems like we could drop the temporary variable entirely here and just use dbConnection.schemaVersion wherever needed. But it's ok this way too, and the rest of the patch looks great. Thanks for adding this feature!
Attachment #270556 - Flags: review?(myk) → review+
It still executes the query each time, so the member variable is probably a good thing to use.
Checking in toolkit/components/contentprefs/src/nsContentPrefService.js; new revision: 1.8; previous revision: 1.7
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Flags: in-testsuite-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: