Fix to queryPrefix and LIKE queries

This commit is contained in:
Zef Hemel
2022-10-14 16:49:45 +02:00
parent fe77d44745
commit 68809ff958
4 changed files with 11 additions and 6 deletions
+5 -3
View File
@@ -88,7 +88,8 @@ export function pageIndexSyscalls(db: SQLite): SysCallMapping {
return (
await asyncQuery<Item>(
db,
`SELECT key, page, value FROM ${tableName} WHERE key LIKE "${prefix}%"`,
`SELECT key, page, value FROM ${tableName} WHERE key LIKE ?`,
`${prefix}%`,
)
).map(({ key, value, page }) => ({
key,
@@ -116,11 +117,12 @@ export function pageIndexSyscalls(db: SQLite): SysCallMapping {
"index.deletePrefixForPage": async (ctx, page: string, prefix: string) => {
await asyncExecute(
db,
`DELETE FROM ${tableName} WHERE key LIKE "${prefix}%" AND page = ?`,
`DELETE FROM ${tableName} WHERE key LIKE ? AND page = ?`,
`${prefix}%`,
page,
);
},
"index.clearPageIndex": async (ctx) => {
"index.clearPageIndex": async () => {
await asyncExecute(
db,
`DELETE FROM ${tableName}`,