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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected kw_variadic token: "variadic" #402

Open
jlambert23 opened this issue May 8, 2024 · 0 comments
Open

Unexpected kw_variadic token: "variadic" #402

jlambert23 opened this issue May 8, 2024 · 0 comments

Comments

@jlambert23
Copy link

jlambert23 commented May 8, 2024

Describe the bug

I was following the instructions to dump my schema in the FAQ and received the following error when parsing the dumped sql. I isolated a function to demonstrate the error for this issue:

馃挃 Your query failed to parse.
    This is most likely due to a SQL syntax error. However, you might also have hit a bug, or an unimplemented feature of pg-mem.
    If this is the case, please file an issue at https://github.com/oguimbal/pg-mem along with a query that reproduces this syntax error.

    馃憠 Failed query:

        CREATE FUNCTION public.f_concat_ws(text, VARIADIC text []) RETURNS text LANGUAGE sql IMMUTABLE AS $ _ $
    SELECT
      array_to_string($ 2, $ 1) $ _ $;;

    馃拃 Syntax error at line 1 col 42:

    1  CREATE FUNCTION public.f_concat_ws(text, VARIADIC text []) RETURNS text LANGUAGE sql IMMUTABLE AS $ _ $
                                                ^
    2  SELECT
    3    array_to_string($ 2, $ 1) $ _ $;;
    Unexpected kw_variadic token: "variadic". Instead, I was expecting to see one of the following:

        - A "kw_in" token
        - A "kw_primary" token
        - A "kw_unique" token
        - A "quoted_word" token
        - A "word" token
        - A "word" token
        - A "word" token
        - A "word" token
        - A "kw_current_schema" token
        - A "word" token
        - A "word" token
        - A "word" token
        - A "word" token
        - A "kw_precision" token

       5 | export const createInMemoryDb = async () => {
       6 |   const db = newDb();
    >  7 |   db.public.none(fs.readFileSync("./data/test-dump.sql", "utf8"));
         |             ^
       8 |
       9 |   const knex: Knex = db.adapters.createKnex();
      10 |   await knex.migrate.latest();

      at parseSql (node_modules/pg-mem/src/parser/parse-cache.ts:55:15)
      at DbSchema.parse (node_modules/pg-mem/src/schema/schema.ts:93:28)
      at DbSchema.queries (node_modules/pg-mem/src/schema/schema.ts:103:31)
          at queries.next (<anonymous>)
      at DbSchema.query (node_modules/pg-mem/src/schema/schema.ts:79:20)
      at DbSchema.none (node_modules/pg-mem/src/schema/schema.ts:47:14)
      at none (test/in-memory-db.ts:7:13)
      at Object.<anonymous> (jest.setup.ts:9:25)

To Reproduce

CREATE FUNCTION public.f_concat_ws(text, VARIADIC text[]) RETURNS text
    LANGUAGE sql IMMUTABLE
    AS $_$SELECT array_to_string($2, $1)$_$;

pg-mem version

2.8.1

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