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

feat: support "create schema" #63

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

cvng
Copy link
Contributor

@cvng cvng commented Dec 12, 2023

What kind of change does this PR introduce?

In the continuation of #61 & #51. Ultimately, being able to parse most of the DDL statements would be nice

What is the current behavior?

Parser panics:

could not find node for token Token { kind: Create, text: "CREATE", span: 0..6, token_type: ReservedKeyword } at depth 1

What is the new behavior?

Parser returns:

        CreateSchemaStmt(
            CreateSchemaStmt {
                schemaname: "test",
                authrole: Some(
                    RoleSpec {
                        roletype: RolespecCstring,
                        rolename: "joe",
                        location: 47,
                    },
                ),
                schema_elts: [],
                if_not_exists: true,
            },
        ),

Additional context

Add any other context or screenshots.

@psteinroe
Copy link
Collaborator

thanks @cvng! for an easier review, could you always put the output from libpg_query into the pr? I added the respective log in #64. I will also create a pr template for it. example for a different statement:

CreateDomainStmt(
            CreateDomainStmt {
                domainname: [
                    Node {
                        node: Some(
                            String(
                                String {
                                    sval: "us_postal_code",
                                },
                            ),
                        ),
                    },
                ],
                type_name: Some(
                    TypeName {
                        names: [
                            Node {
                                node: Some(
                                    String(
                                        String {
                                            sval: "text",
                                        },
                                    ),
                                ),
                            },
                        ],
                        type_oid: 0,
                        setof: false,
                        pct_type: false,
                        typmods: [],
                        typemod: -1,
                        array_bounds: [],
                        location: 32,
                    },
                ),
                coll_clause: None,
                constraints: [
                    Node {
                        node: Some(
                            Constraint(
                                Constraint {
                                    contype: ConstrCheck,
                                    conname: "",
                                    deferrable: false,
                                    initdeferred: false,
                                    location: 37,
                                    is_no_inherit: false,
                                    raw_expr: Some(
                                        Node {
                                            node: Some(
                                                NullTest(
                                                    NullTest {
                                                        xpr: None,
                                                        arg: Some(
                                                            Node {
                                                                node: Some(
                                                                    ColumnRef(
                                                                        ColumnRef {
                                                                            fields: [
                                                                                Node {
                                                                                    node: Some(
                                                                                        String(
                                                                                            String {
                                                                                                sval: "value",
                                                                                            },
                                                                                        ),
                                                                                    ),
                                                                                },
                                                                            ],
                                                                            location: 44,
                                                                        },
                                                                    ),
                                                                ),
                                                            },
                                                        ),
                                                        nulltesttype: IsNotNull,
                                                        argisrow: false,
                                                        location: 50,
                                                    },
                                                ),
                                            ),
                                        },
                                    ),
                                    cooked_expr: "",
                                    generated_when: "",
                                    nulls_not_distinct: false,
                                    keys: [],
                                    including: [],
                                    exclusions: [],
                                    options: [],
                                    indexname: "",
                                    indexspace: "",
                                    reset_default_tblspc: false,
                                    access_method: "",
                                    where_clause: None,
                                    pktable: None,
                                    fk_attrs: [],
                                    pk_attrs: [],
                                    fk_matchtype: "",
                                    fk_upd_action: "",
                                    fk_del_action: "",
                                    fk_del_set_cols: [],
                                    old_conpfeqop: [],
                                    old_pktable_oid: 0,
                                    skip_validation: false,
                                    initially_valid: true,
                                },
                            ),
                        ),
                    },
                ],
            },
        ),

@cvng
Copy link
Contributor Author

cvng commented Dec 12, 2023

sure! I will rebase once #64 merged. +1 for a pr template

Copy link
Collaborator

@psteinroe psteinroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@psteinroe psteinroe merged commit 9160453 into supabase-community:main Dec 12, 2023
1 check passed
@cvng cvng deleted the create-schema branch December 12, 2023 17:36
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 this pull request may close these issues.

2 participants