sql-parser-cst
sql-parser-cst copied to clipboard
Using PostgreSQL namespaced data types results in syntax error
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);
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