Skip to content

Commit

Permalink
optional semicolon for sql queries
Browse files Browse the repository at this point in the history
  • Loading branch information
karooolis committed Dec 19, 2024
1 parent b0b42a9 commit ee1695b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)) {
Expand Down

0 comments on commit ee1695b

Please sign in to comment.