fix: infer postgres field (#3663)
This commit is contained in:
parent
677eb152e0
commit
46daba1e6e
@ -34,7 +34,7 @@ describe('view inference', function () {
|
|||||||
|
|
||||||
await db.sync();
|
await db.sync();
|
||||||
|
|
||||||
const viewName = 'user_posts';
|
const viewName = 'test_view';
|
||||||
|
|
||||||
const dropViewSQL = `DROP VIEW IF EXISTS ${viewName}`;
|
const dropViewSQL = `DROP VIEW IF EXISTS ${viewName}`;
|
||||||
await db.sequelize.query(dropViewSQL);
|
await db.sequelize.query(dropViewSQL);
|
||||||
|
@ -153,10 +153,14 @@ export default class PostgresQueryInterface extends QueryInterface {
|
|||||||
|
|
||||||
// handle column alias
|
// handle column alias
|
||||||
const from = ast[0].from;
|
const from = ast[0].from;
|
||||||
const findAs = from.find((from) => from.as === columnExprTable);
|
if (columnExprTable === null && column.expr.type === 'column_ref') {
|
||||||
|
columnExprTable = from[0].table;
|
||||||
|
} else {
|
||||||
|
const findAs = from.find((from) => from.as === columnExprTable);
|
||||||
|
|
||||||
if (findAs) {
|
if (findAs) {
|
||||||
columnExprTable = findAs.table;
|
columnExprTable = findAs.table;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return columnUsage.column_name === column.expr.column && columnUsage.table_name === columnExprTable;
|
return columnUsage.column_name === column.expr.column && columnUsage.table_name === columnExprTable;
|
||||||
|
Loading…
Reference in New Issue
Block a user