Fix to queryPrefix and LIKE queries
This commit is contained in:
@@ -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}`,
|
||||
|
||||
Reference in New Issue
Block a user