Fix to queryPrefix and LIKE queries
parent
fe77d44745
commit
68809ff958
|
@ -99,7 +99,8 @@ export function storeSyscalls(
|
||||||
"store.deletePrefix": async (_ctx, prefix: string) => {
|
"store.deletePrefix": async (_ctx, prefix: string) => {
|
||||||
await asyncExecute(
|
await asyncExecute(
|
||||||
db,
|
db,
|
||||||
`DELETE FROM ${tableName} WHERE key LIKE "${prefix}%"`,
|
`DELETE FROM ${tableName} WHERE key LIKE ?`,
|
||||||
|
`${prefix}%`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
"store.deleteQuery": async (_ctx, query: Query) => {
|
"store.deleteQuery": async (_ctx, query: Query) => {
|
||||||
|
@ -152,7 +153,8 @@ export function storeSyscalls(
|
||||||
return (
|
return (
|
||||||
await asyncQuery<Item>(
|
await asyncQuery<Item>(
|
||||||
db,
|
db,
|
||||||
`SELECT key, value FROM ${tableName} WHERE key LIKE "${prefix}%"`,
|
`SELECT key, value FROM ${tableName} WHERE key LIKE ?`,
|
||||||
|
`${prefix}%`,
|
||||||
)
|
)
|
||||||
).map(({ key, value }) => ({
|
).map(({ key, value }) => ({
|
||||||
key,
|
key,
|
||||||
|
|
|
@ -24,7 +24,6 @@ export async function updateMaterializedQueriesCommand() {
|
||||||
currentPage,
|
currentPage,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
console.log("Going reload the page");
|
|
||||||
await editor.reloadPage();
|
await editor.reloadPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,6 +283,7 @@ export class HttpServer {
|
||||||
const name = ctx.params.name;
|
const name = ctx.params.name;
|
||||||
const plugName = ctx.params.plug;
|
const plugName = ctx.params.plug;
|
||||||
const args = await ctx.request.body().value;
|
const args = await ctx.request.body().value;
|
||||||
|
console.log("Got args", args, "for", name, "in", plugName);
|
||||||
const plug = this.system.loadedPlugs.get(plugName);
|
const plug = this.system.loadedPlugs.get(plugName);
|
||||||
if (!plug) {
|
if (!plug) {
|
||||||
ctx.response.status = 404;
|
ctx.response.status = 404;
|
||||||
|
@ -298,6 +299,7 @@ export class HttpServer {
|
||||||
ctx.response.headers.set("Content-Type", "application/json");
|
ctx.response.headers.set("Content-Type", "application/json");
|
||||||
ctx.response.body = JSON.stringify(result);
|
ctx.response.body = JSON.stringify(result);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
console.log("Error", e);
|
||||||
ctx.response.status = 500;
|
ctx.response.status = 500;
|
||||||
ctx.response.body = e.message;
|
ctx.response.body = e.message;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -88,7 +88,8 @@ export function pageIndexSyscalls(db: SQLite): SysCallMapping {
|
||||||
return (
|
return (
|
||||||
await asyncQuery<Item>(
|
await asyncQuery<Item>(
|
||||||
db,
|
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 }) => ({
|
).map(({ key, value, page }) => ({
|
||||||
key,
|
key,
|
||||||
|
@ -116,11 +117,12 @@ export function pageIndexSyscalls(db: SQLite): SysCallMapping {
|
||||||
"index.deletePrefixForPage": async (ctx, page: string, prefix: string) => {
|
"index.deletePrefixForPage": async (ctx, page: string, prefix: string) => {
|
||||||
await asyncExecute(
|
await asyncExecute(
|
||||||
db,
|
db,
|
||||||
`DELETE FROM ${tableName} WHERE key LIKE "${prefix}%" AND page = ?`,
|
`DELETE FROM ${tableName} WHERE key LIKE ? AND page = ?`,
|
||||||
|
`${prefix}%`,
|
||||||
page,
|
page,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
"index.clearPageIndex": async (ctx) => {
|
"index.clearPageIndex": async () => {
|
||||||
await asyncExecute(
|
await asyncExecute(
|
||||||
db,
|
db,
|
||||||
`DELETE FROM ${tableName}`,
|
`DELETE FROM ${tableName}`,
|
||||||
|
|
Loading…
Reference in New Issue