Skip to content

Wrong Typing of SelectStm.valuesLists #17

Description

@jens-f

Great project, the typing is wonderful for building complex functionality.
It seems that there might be an issue in the typing of SelectStmt.valuesLists:

In @pg-nano/pg-parser/lib/ast.d.ts

export type SelectStmt = {
...
    valuesLists?: List<Expr>[];
...
}

But looking at the actual parser output, the type should probably be defined as such

export type SelectStmt = {
...
    valuesLists?: {List: List<Expr>}[];
...
}

Steps to reproduce:

INSERT INTO users (id, name, email)
VALUES (1, 'John', NULL);

It is parsed into this

{
  stmt: {
    InsertStmt: {
      relation: {
        relname: "users",
        inh: true,
        relpersistence: "p",
        location: 194,
      },
      cols: [
        {
          ResTarget: {
            name: "id",
            location: 201,
          },
        },
        {
          ResTarget: {
            name: "name",
            location: 205,
          },
        },
        {
          ResTarget: {
            name: "email",
            location: 211,
          },
        },
      ],
      selectStmt: {
        SelectStmt: {
          valuesLists: [
            {
              List: {
                items: [
                  {
                    A_Const: {
                      ival: {
                        ival: 1,
                      },
                      location: 226,
                    },
                  },
                  {
                    A_Const: {
                      sval: {
                        sval: "John",
                      },
                      location: 229,
                    },
                  },
                  {
                    A_Const: {
                      isnull: true,
                      location: 237,
                    },
                  },
                ],
              },
            },
          ],
          limitOption: "LIMIT_OPTION_DEFAULT",
          op: "SETOP_NONE",
        },
      },
      override: "OVERRIDING_NOT_SET",
    },
  },
  stmt_location: 181,
  stmt_len: 61,
}

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