Column.indices may contain the index from another schema
Closed this issue · 0 comments
orangain commented
If there is an index with the same table name and column name in another schema, the index of the other schema is acquired by extractSchemas
.
Reproducible code:
test("it should extract indices", async ({ knex: [db] }) => {
await db.raw(`
create table test.some_table (id integer);
create index some_table_id_idx on test.some_table (id);
create schema test2;
create table test2.some_table (id integer);
create index some_table_id_idx2 on test2.some_table (id);
`);
const result = await extractTable(db, makePgType("some_table"));
const expected: Index[] = [
{
isPrimary: false,
name: "some_table_id_idx",
},
];
expect(result.columns[0].indices).toStrictEqual(expected);
});
Expected behavior:
The test passes.
Actual behavior:
The test fails because the indices
contains the index from another schema:
AssertionError: expected [ { …(2) }, { …(2) } ] to strictly equal [ { isPrimary: false, …(1) } ]
- Expected
+ Received
Array [
Object {
"isPrimary": false,
"name": "some_table_id_idx",
},
+ Object {
+ "isPrimary": false,
+ "name": "some_table_id_idx2",
+ },
]
Version:
Reproduced in the latest main branch.