oguimbal / pg-mem

An in memory postgres DB instance for your unit tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`using` in table alter

phawxby opened this issue · comments

Describe the bug

Knex has the following migration code

  return knex.schema.alterTable('foo', (table) => {
    table.bigint('bar').alter().notNullable();
    table.primary(['bar']);
  });

This generates the SQL

alter table "foo" alter column "bar" type bigint using ("bar"::bigint);

And the error

alter table "foo" alter column "bar" type bigint using ("bar"::bigint) - 💔 Your query failed to parse.
rig-data:test:dev: This is most likely due to a SQL syntax error.


alter table "foo" alter column "bar" type bigint using ("bar"::bigint);
                                                 ^
Unexpected kw_using token: "using". Instead, I was expecting to see one of the following:

- A "dot" token
- A "lparen" token
- A "kw_array" token
- A "lbracket" token
- A "comma" token
- A "semicolon" token

Looking at the Postgres docs that is valid syntax

ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ]
pg-mem: 2.6.13