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 for CREATE RULE #142

Open
seveibar opened this issue Oct 9, 2023 · 0 comments
Open

Support for CREATE RULE #142

seveibar opened this issue Oct 9, 2023 · 0 comments

Comments

@seveibar
Copy link

seveibar commented Oct 9, 2023

(@seamapi is open to sponsor this repo/fix)

Example failing syntax:

CREATE RULE override_insert AS ON INSERT TO public.events DO INSTEAD (
    INSERT INTO public.events
    VALUES (NEW.*)
    RETURNING *
  );
  CREATE RULE parsing

  tests/ast-capabilities.test.ts:6

   5:   const statements =
   6:     parse(`CREATE RULE override_insert AS ON INSERT TO public.events DO INSTEAD (
   7:     INSERT INTO public.events

  Error thrown in test:

  Error {
    offset: 2,
    token: {
      col: 13,
      line: 1,
      lineBreaks: 0,
      offset: 12,
      text: 'override_insert',
      toString: Function tokenToString {},
      type: 'word',
      value: 'override_insert',
    },
    message: `Syntax error at line 1 col 13:␊
    ␊
    1      VALUES (NEW.*)␊
                   ^␊
    2      RETURNING *␊
    3    );␊
    Unexpected word token: "override_insert". I did not expect any more input. Here is the state of my parse table:␊
    ␊
        kw_view → %word ● ␊
        kw_recursive → %word ● ␊
        kw_global → %word ● ␊
        kw_local → %word ● ␊
        kw_unlogged → %word ● ␊
        kw_index → %word ● ␊
        kw_sequence → %word ● ␊
        kw_temporary → %word ● ␊
        kw_temp → %word ● ␊
        kw_function → %word ● ␊
        kw_extension → %word ● ␊
        kw_type → %word ● ␊
        kw_materialized → %word ● ␊
        kw_schema → %word ● ␊
    `,
  }

  › kw_schema → %word ●
  › Parser.feed (node_modules/nearley/lib/nearley.js:343:27)
  › _parse (node_modules/pgsql-ast-parser/src/parser.ts:110:16)
  › doParse (node_modules/pgsql-ast-parser/src/parser.ts:57:27)
  › parse (node_modules/pgsql-ast-parser/src/parser.ts:60:11)
  › <anonymous> (tests/ast-capabilities.test.ts:6:5)
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

1 participant