Open motherway opened 1 month ago
Thanks for reporting.
Unfortunately this is a problem that's pretty much impossible to fix with the current architecture of SQL Formatter. This is because foo-bar.baz.zap
would have to be treated differently based on the context:
FROM
-clause it needs to be parsed as project-name.table.column
.identifier - identifer.field.field
.SQL Formatter doesn't properly parse the SQL, so it can't really tell when it should treat it in one or the other way. I guess one option would be to always parse such constructs as project-name
, as this way the formatter would avoid introducing syntax errors.
Anyway... Because of problems like that I created another SQL formatting tool prettier-plugin-sql-cst which does have a pretty solid BigQuery support and it does not suffer from issues like this. I suggest you give it a try.
PS. Just FYI, when reporting bugs to this or any other open-source project, please don't answer "latest" when asked which version number you're using. That "latest" will no more be the latest version when somebody looks at this bug report a year from now. Or I might have released a new version just minutes ago, and would not have any idea whether your definition of "latest" refers to that version or some earlier one.
PS. Just FYI, when reporting bugs to this or any other open-source project, please don't answer "latest" when asked which version number you're using. That "latest" will no more be the latest version when somebody looks at this bug report a year from now. Or I might have released a new version just minutes ago, and would not have any idea whether your definition of "latest" refers to that version or some earlier one.
That makes total sense. Apologies I wrote it in a hurry.
Whenever a project name contains a dash followed by a number then it is being interpreted as a minus number value and being separated when formatted. This is troublesome for us as a lot of our project names contain this format and the formatter is breaking our queries as a result.
We can't always rely on escaping the project name as these queries are written by end users in the browser.
Input data
Expected Output
Actual Output
Usage