backstage-plugin-toolbox icon indicating copy to clipboard operation
backstage-plugin-toolbox copied to clipboard

SQL formatter doesn't like ~ in statements

Open zjpersc opened this issue 1 year ago • 1 comments

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

zjpersc avatar May 17 '24 19:05 zjpersc

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?

drodil avatar May 17 '24 19:05 drodil