Skip to content

Support create type statement in core grammer #533

Description

@griffio

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions