nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst
https://nene.github.io/prettier-sql-playground/
GNU General Public License v3.0
123 stars 7 forks source link

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

Closed iwilsonv closed 1 year ago

iwilsonv commented 1 year ago

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().

nene commented 1 year ago

Which SQL flavor are you using?

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

iwilsonv commented 1 year ago

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.