From ee1695b84b64fbea8504c0b88b966b70bfa57a34 Mon Sep 17 00:00:00 2001 From: karooolis Date: Thu, 19 Dec 2024 08:40:09 +0200 Subject: [PATCH] optional semicolon for sql queries --- .../worlds/[worldAddress]/explore/useQueryValidator.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/useQueryValidator.ts b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/useQueryValidator.ts index 2b65ee70f7..b7aa9e6466 100644 --- a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/useQueryValidator.ts +++ b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/useQueryValidator.ts @@ -36,6 +36,10 @@ function findErrorPosition(query: string, target: string) { }; } +function formatQuery(query: string) { + return query.endsWith(";") ? query : `${query};`; +} + export function useQueryValidator(table?: Table) { const monaco = useMonaco(); const { worldAddress } = useParams(); @@ -46,7 +50,7 @@ export function useQueryValidator(table?: Table) { (query: string) => { if (!monaco || !table) return true; - const decodedQuery = decodeURIComponent(query); + const decodedQuery = formatQuery(decodeURIComponent(query)); try { const ast = sqlParser.astify(decodedQuery); if ("columns" in ast && Array.isArray(ast.columns)) {