sql-parser-cst icon indicating copy to clipboard operation
sql-parser-cst copied to clipboard

Using PostgreSQL namespaced data types results in syntax error

Open nene opened this issue 11 months ago • 1 comments

For example:

CREATE TYPE public.my_type AS ENUM('a', 'b', 'c');

SELECT 'a'::public.my_type;

The select statement produces a parse error:

Syntax Error: Unexpected "."
Was expecting to see: ...
--> undefined:3:15
  |
3 | SELECT 'a'::public.my_type;
  |                   ^

Similarly in CREATE TABLE:

CREATE TABLE foo (id public.my_type);

nene avatar Apr 08 '25 18:04 nene

As we implement this, we should make sure that we parse the schema name as identifier and the data type name as data type. Something like:

public.INT   --> namespaced_data_type
                      /          \
                  schema      data_type
                    /               \
                public              INT

nene avatar Apr 08 '25 19:04 nene