auxten / postgresql-parser

Pure Golang PostgreSQL (SQL:2011, SQL:2008, SQL:2003, SQL:1999, and SQL-92 Standard) Parser
Apache License 2.0
273 stars 50 forks source link

Data type STRING not recognized #15

Open MFAshby opened 2 years ago

MFAshby commented 2 years ago

Hi,

I'm experimenting with postgresql-parser to intercept and rewrite some queries to a postgresql database.

One problem I have encountered is that the formatter will output "STRING" by default for string data type. PostgreSQL does not support this, instead the data type name is "TEXT". CockroachDB supports "TEXT" as an alias for "STRING" [1]

In order to make query-rewriting work, I've patched postgresql-parser to output "TEXT" data type by default instead of "STRING". I think this could be a reasonable default since CockroachDB supports both.

[1] https://www.cockroachlabs.com/docs/stable/string.html