Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support create type statement in core grammer #533

Open
griffio opened this issue Jul 14, 2023 · 0 comments
Open

Support create type statement in core grammer #533

griffio opened this issue Jul 14, 2023 · 0 comments

Comments

@griffio
Copy link
Contributor

griffio commented Jul 14, 2023

In PostgreSql, CREATE TYPE is used for Enums, Ranges and Composite types. https://www.postgresql.org/docs/15/sql-createtype.html

The ALTER TYPE statement would also have to be added.

Based on the feature request sqldelight/sqldelight#4339, I created a minimum attempt to
implement CREATE TYPE ... AS ENUM.

I tried this with a local snapshot -> master...griffio:sql-psi:create-type and sqldelight/sqldelight@master...griffio:sqldelight:add-postgres-enum-type

Initially, I tried using the extension_stmt in the core sql.bnf but it needs have it's own statement to avoid ambiguity.
Currently, the sql-delight database generator outputs create table schema elements first, create type needs to be before these and have a dedicated type that can be selected in TreeUtil.

Examples of known schema creation statements in SQL dialects

CREATE DATABASE (Non standard variably supported)
CREATE DOMAIN (Non standard supported by Postgres)
CREATE INDEX (Non standard and supported)
CREATE SCHEMA (Standard variably supported)
CREATE SEQUENCE (Standard but extended by Postgres)
CREATE TABLE (Standard and supported)
CREATE TYPE (Non standard but supported by Postgres)
CREATE VIEW (Standard and supported)

This is also the same for ALTER and DROP statements - I believe that the core grammar should have these place-holder statements that can be overridden by Dialects

🥫 It maybe that this feature can be deferred till after 2.0 is released and more breaking changes could be supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant