Open Bug 1459218 Opened 7 years ago Updated 2 years ago

Remove DBConn() and other synchronous mozStorage calls from Places tests

Categories

(Toolkit :: Places, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: mak, Unassigned, Mentored)

Details

Attachments

(1 file)

Quite some Places tests are still using synchronous mozStorage APIs and accessors: DBConn() from head_common.js should be removed, then the consumers: https://searchfox.org/mozilla-central/search?q=DBConn%28%29&path=places%2Ftests&case=false&regexp=false ... should be replaced with Sqlite.jsm syntax (using await PlacesUtils.promiseDBConnection() if it's a read or PlacesUtils.withConnectionWrapper for writes)
Severity: normal → S3
Mentor: mak
Whiteboard: [fxsearch]

Hello, can I please work on this? Thank you.

Bugs are assigned automatically when a patch is attached.

The scope of the bug is to remove DBConn() from https://searchfox.org/mozilla-central/rev/5f7ad06a2cffb7eda69229238b15198994b548e0/toolkit/components/places/tests/head_common.js#101-134 and then fix all the callers using Sqlite.sys.mjs syntax, that means one of:
Read-only SELECT query:

let db = await PlacesUtils.promiseDatabaseConnection();
let rows = await db.execute(<sql_query>, <query_params>);

Read/write query:

await PlacesUtils.withConnectionWrapper(<unique_label>, async db => {
  await db.execute(<sql_query>, <query_params>);
});

There are many examples, you can search on searchfox.org

After modifying the code, you can ./mach build faster and ./mach test toolkit/components/places to verify

Sir, I tried my best to understand this bug and made an example change. I will be thankful if you can review this and guide me whether I am doing correct or not - https://paste.mozilla.org/Efo68igt

(In reply to Abhishek from comment #3)

Sir, I tried my best to understand this bug and made an example change. I will be thankful if you can review this and guide me whether I am doing correct or not - https://paste.mozilla.org/Efo68igt

It's mostly ok, though row should be rows because execute may indeed return 0, 1 or multiple rows.
There's also no .dispose() since that's just an array, it will be garbage collected. So you don't need the try/finally.
Then of course the function was synchronous, the new one is asynchronous, so the callers must be fixed.

I placed this under WIP because until now, I only modified one file, and I am not sure if everything is correct, especially about the dump_table function. Please have a quick review and I will update other files also

Assignee: nobody → tiwari.abhishektiwari23
Attachment #9324286 - Attachment description: WIP: Bug 1459218 - Remove DBConn() and other synchronous mozStorage calls from Places tests r=mak → Bug 1459218 - Remove DBConn() and other synchronous mozStorage calls from Places tests r=mak
Status: NEW → ASSIGNED

Sir, my end-semester exams are going to start this week. Once my exams will over, I will continue with this bug. Thanks

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: tiwari.abhishektiwari23 → nobody
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: