drodil / backstage-plugin-toolbox

Most commonly used developer tools within Backstage
MIT License
46 stars 25 forks source link

SQL formatter doesn't like ~ in statements #98

Open zjpersc opened 5 months ago

zjpersc commented 5 months ago

I'm trying to use the SQL Beautifier with a query, but it throws an error if there's a tilde in the query. I'm using version 1.20.3.

Example: SELECT bar, foo FROM foo_bar WHERE customer_prefix_name ~ '^.*\\d{9}.*$' GROUP BY bar

Error: Parse error: Unexpected "~ '^.*\\d{" at line 1 column 57

Expected output:

SELECT
  bar,
  foo
FROM
  foo_bar
WHERE
  ~ customer_prefix_name '^.*\\d{9}.*$'
GROUP BY
  bar
drodil commented 5 months ago

Hi, thanks for the report! The tool is using sql-formatter library (https://github.com/sql-formatter-org/sql-formatter) to do the formatting. Maybe this should be reported there or check if there's any open issues about this?