1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Chore: Migrate SQL queries in preparation for web support (#10670)

This commit is contained in:
Henry Heino
2024-07-01 10:56:40 -07:00
committed by GitHub
parent 337d50437b
commit d89be23069
14 changed files with 33 additions and 33 deletions

View File

@@ -247,7 +247,7 @@ export default class BaseItem extends BaseModel {
let output: any[] = [];
for (let i = 0; i < classes.length; i++) {
const ItemClass = this.getClass(classes[i]);
const sql = `SELECT * FROM ${ItemClass.tableName()} WHERE id IN ("${ids.join('","')}")`;
const sql = `SELECT * FROM ${ItemClass.tableName()} WHERE id IN ('${ids.join('\',\'')}')`;
const models = await ItemClass.modelSelectAll(sql);
output = output.concat(models);
}
@@ -261,7 +261,7 @@ export default class BaseItem extends BaseModel {
const fields = options && options.fields ? options.fields : [];
const ItemClass = this.getClassByItemType(itemType);
const fieldsSql = fields.length ? this.db().escapeFields(fields) : '*';
const sql = `SELECT ${fieldsSql} FROM ${ItemClass.tableName()} WHERE id IN ("${ids.join('","')}")`;
const sql = `SELECT ${fieldsSql} FROM ${ItemClass.tableName()} WHERE id IN ('${ids.join('\',\'')}')`;
return ItemClass.modelSelectAll(sql);
}
@@ -300,7 +300,7 @@ export default class BaseItem extends BaseModel {
// since no other client have (or should have) them.
let conflictNoteIds: string[] = [];
if (this.modelType() === BaseModel.TYPE_NOTE) {
const conflictNotes = await this.db().selectAll(`SELECT id FROM notes WHERE id IN ("${ids.join('","')}") AND is_conflict = 1`);
const conflictNotes = await this.db().selectAll(`SELECT id FROM notes WHERE id IN ('${ids.join('\',\'')}') AND is_conflict = 1`);
conflictNoteIds = conflictNotes.map((n: NoteEntity) => {
return n.id;
});
@@ -654,7 +654,7 @@ export default class BaseItem extends BaseModel {
whereSql = [`(encryption_applied = 1 OR (${blobDownloadedButEncryptedSql})`];
}
if (exclusions.length) whereSql.push(`id NOT IN ("${exclusions.join('","')}")`);
if (exclusions.length) whereSql.push(`id NOT IN ('${exclusions.join('\',\'')}')`);
const sql = sprintf(
`
@@ -936,7 +936,7 @@ export default class BaseItem extends BaseModel {
});
if (!ids.length) continue;
await this.db().exec(`UPDATE sync_items SET force_sync = 1 WHERE item_id IN ("${ids.join('","')}")`);
await this.db().exec(`UPDATE sync_items SET force_sync = 1 WHERE item_id IN ('${ids.join('\',\'')}')`);
}
}