nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst

Home Page:https://nene.github.io/prettier-sql-playground/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Unexpected ":"" error when casting with double colon

iwilsonv opened this issue · comments

For example, if you put select new_col::int from client limit 100 in https://nene.github.io/prettier-sql-playground/ you will get an "unexpected ':'" error.

This is also a problem in sql-formatter, which is what we're currently using, so it would be nice to fix it there too.

:: can mean different things in different sql flavors, but it's not viable for us to change all of our uses to be CAST().

Which SQL flavor are you using?

Currently the plugin only supports SQLite and BigQuery. To my knowledge neither supports the :: operator.

Good point. I missed that. It's Postgres, so I guess we don't expect it to work here.

For sql-formatter I had missed the language and formatDialect options because otherwise the default didn't seem to have any issues. Specifying postgresql handles this cast operator correctly.

Thanks for pointing me the right direction.