Skip to content

Commit

Permalink
Don't fail on SQL format errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pgiraud committed Nov 13, 2024
1 parent 336dc81 commit 3d06179
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions powa/static/js/utils/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { formatDialect, postgresql } from "sql-formatter";
hljs.registerLanguage("sql", pgsql);

export function formatSql(value) {
value = formatDialect(value, { dialect: postgresql });
return hljs.highlightAuto(value, ["sql"]).value;
try {
value = formatDialect(value, { dialect: postgresql });
value = hljs.highlightAuto(value, ["sql"]).value;
} catch (error) {
console.error("Could not highlight SQL:", value);
}
return value;
}

0 comments on commit 3d06179

Please sign in to comment.