Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/driver/postgres/PostgresQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2019,9 +2019,26 @@ export class PostgresQueryRunner extends BaseQueryRunner implements QueryRunner
}
const result = await this.query(`SELECT "udt_schema", "udt_name" ` +
`FROM "information_schema"."columns" WHERE "table_schema" = '${schema}' AND "table_name" = '${name}' AND "column_name"='${column.name}'`);

let udtName = result[0]["udt_name"];

// You can not modify the array type. You need to edit the enum itself.
if (column.isArray) {
// Find the information about the array type
const typeResult = await this.query(`select "typelem" from pg_type where "typname" = '${udtName}';`);

const typelem = typeResult[0]["typelem"];
// Get with the oid of the enum array type the enum type
const baseTypeNameResult = await this.query(`select "typname" from pg_type where oid = ${typelem}`);

const baseTypeName = baseTypeNameResult[0]["typname"];

// Replace the udtName with the enum type
udtName = baseTypeName;
}
return {
enumTypeSchema: result[0]["udt_schema"],
enumTypeName: result[0]["udt_name"]
enumTypeName: udtName
};
}

Expand Down