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
+4 -2
View File
@@ -99,7 +99,8 @@ export function storeSyscalls(
"store.deletePrefix": async (_ctx, prefix: string) => {
await asyncExecute(
db,
`DELETE FROM ${tableName} WHERE key LIKE "${prefix}%"`,
`DELETE FROM ${tableName} WHERE key LIKE ?`,
`${prefix}%`,
);
},
"store.deleteQuery": async (_ctx, query: Query) => {
@@ -152,7 +153,8 @@ export function storeSyscalls(
return (
await asyncQuery<Item>(
db,
`SELECT key, value FROM ${tableName} WHERE key LIKE "${prefix}%"`,
`SELECT key, value FROM ${tableName} WHERE key LIKE ?`,
`${prefix}%`,
)
).map(({ key, value }) => ({
key,