oguimbal / pg-mem

An in memory postgres DB instance for your unit tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Corrupted alias error when adding enum column to table with multikey index

zookatron opened this issue Β· comments

Describe the bug

Error: alter table "enclaves_users" add column "state" text check ("state" in ('ok', 'failed', 'pending')) - Corrupted alias

πŸ’₯ This is a nasty error, which was unexpected by pg-mem. Also known "a bug" 😁 Please file an issue !

*️⃣ Failed SQL statement: alter table "enclaves_users" add column "state" text check ("state" in ('ok', 'failed', 'pending'));

πŸ‘‰ You can file an issue at https://github.com/oguimbal/pg-mem along with a way to reproduce this error (if you can), and  the stacktrace:

    at Alias._getColumn (/node_modules/pg-mem/index.js:5372:19)
    at Alias.getColumn (/node_modules/pg-mem/index.js:5344:26)
    at _buildValueReal (/node_modules/pg-mem/index.js:1434:37)
    at _buildValue (/node_modules/pg-mem/index.js:1408:11)
    at buildIn (/node_modules/pg-mem/index.js:1591:21)
    at _buildValueReal (/node_modules/pg-mem/index.js:1426:24)
    at _buildValue (/node_modules/pg-mem/index.js:1408:11)
    at buildValue (/node_modules/pg-mem/index.js:1379:17)
    at /node_modules/pg-mem/index.js:8298:111
    at StackOf.usingValue (/node_modules/pg-mem/index.js:1117:24) {
  location: { start: 0, end: 0 },
  [Symbol(errorDetailsIncluded)]: true
}

To Reproduce

package.json:

{
  "type": "module",
  "dependencies": {
    "knex": "2.5.1",
    "pg-mem": "2.6.13"
  }
}

index.js

import { newDb } from "pg-mem";

const database = newDb();
const knex = database.adapters.createKnex();

await knex.schema.createTable('projects_users', (table) => {
  table.integer('project_id').notNullable();
  table.integer('user_id').notNullable();
  table.primary(['project_id', 'user_id']);
});
await knex.schema.table('projects_users', (table) => {
  table.enu('state', ['ok', 'failed', 'pending']);
});

knex.destroy();

pg-mem version

2.6.13