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

DefineStmt is not implemented #42

Closed
divyenduz opened this issue Oct 14, 2021 · 2 comments
Closed

DefineStmt is not implemented #42

divyenduz opened this issue Oct 14, 2021 · 2 comments

Comments

@divyenduz
Copy link

divyenduz commented Oct 14, 2021

To reproduce

const stmts = parse(`
    CREATE AGGREGATE group_concat(text) (
        SFUNC = _group_concat,
        STYPE = text
    );
`)
console.log(stmts)
deparse(stmts[0])

Source database https://github.com/prisma/database-schema-examples/blob/main/postgres/sakila/schema.sql

I ran it on all the databases here https://github.com/prisma/database-schema-examples/tree/main/postgres and this was the only error we got 🎉

@pyramation
Copy link
Collaborator

pyramation commented Oct 19, 2021

thanks! Looking at this one and pasting AST for reference

[
  {
    "RawStmt": {
      "stmt": {
        "DefineStmt": {
          "kind": "OBJECT_AGGREGATE",
          "defnames": [
            {
              "String": {
                "str": "group_concat"
              }
            }
          ],
          "args": [
            {
              "List": {
                "items": [
                  {
                    "FunctionParameter": {
                      "argType": {
                        "names": [
                          {
                            "String": {
                              "str": "text"
                            }
                          }
                        ],
                        "typemod": -1,
                        "location": 30
                      },
                      "mode": "FUNC_PARAM_IN"
                    }
                  }
                ]
              }
            },
            {
              "Integer": {
                "ival": -1
              }
            }
          ],
          "definition": [
            {
              "DefElem": {
                "defname": "sfunc",
                "arg": {
                  "TypeName": {
                    "names": [
                      {
                        "String": {
                          "str": "_group_concat"
                        }
                      }
                    ],
                    "typemod": -1,
                    "location": 54
                  }
                },
                "defaction": "DEFELEM_UNSPEC",
                "location": 46
              }
            },
            {
              "DefElem": {
                "defname": "stype",
                "arg": {
                  "TypeName": {
                    "names": [
                      {
                        "String": {
                          "str": "text"
                        }
                      }
                    ],
                    "typemod": -1,
                    "location": 85
                  }
                },
                "defaction": "DEFELEM_UNSPEC",
                "location": 77
              }
            }
          ]
        }
      },
      "stmt_len": 95
    }
  }
]

@pyramation
Copy link
Collaborator

should be good to go now! Please let me know if you find other issues, thanks again!

 - pgsql-deparser@13.1.11
 - pgsql-parser@13.1.11

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

No branches or pull requests

2 participants