It’s a lot of fun removing old code; it’s less fun when removing that old code breaks lots of things. That’s what happened when bug 589032 was checked in to mozilla-central last week. We had deprecated mozIStorageStatementWrapper
over a year ago; bug 589032 removed mozIStorageStatementWrapper
in favor of using mozIStorageStatement
directly.
As there have been a couple reports of breakage (which likely means there’s a lot more breakage pending), and I have claimed in the bug that fixing said breakage is a straightforward process, here’s the quick-n-dirty guide to doing so. (Warning: may contain bugs or be incomplete. Please note any oversights in the comments.)
Code that created wrappers:
var wrapper = new Components.Constructor("@mozilla.org/storage/statement-wrapper;1",
Ci.mozIStorageStatementWrapper,
"initialize");
function createStatement(db, aSQL) {
return new wrapper(db.createStatement(aSQL));
}
or perhaps:
var wrapper = Cc["@mozilla.org/storage/statement-wrapper;1"]
.createInstance(Ci.mozIStorageStatementWrapper);
wrapper.initialize(statement);
should be replaced with:
function createStatement(db, aSQL) {
return db.createStatement(aSQL);
}
Of course, that’s almost not worth having a separate function for. 🙂
Nearly all of the methods that you were calling on the wrapper remain unchanged, with the exception of:
foo = wrapped_stmt.execute();
That should be replaced with:
foo = stmt.executeStep();
Statements have an execute()
method, but it does something slightly different than the wrapper’s execute()
method.
Finally, where you finalize your statements (you are finalizing your statements, right?):
wrapped_stmt.statement.finalize();
is now simply:
statement.finalize();
As I said earlier, please note any omissions or errors in the comments!