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();
 | 
			
		||||
 | 
			
		||||
    const viewName = 'user_posts';
 | 
			
		||||
    const viewName = 'test_view';
 | 
			
		||||
 | 
			
		||||
    const dropViewSQL = `DROP VIEW IF EXISTS ${viewName}`;
 | 
			
		||||
    await db.sequelize.query(dropViewSQL);
 | 
			
		||||
 | 
			
		||||
@ -153,11 +153,15 @@ export default class PostgresQueryInterface extends QueryInterface {
 | 
			
		||||
 | 
			
		||||
            // handle column alias
 | 
			
		||||
            const from = ast[0].from;
 | 
			
		||||
            if (columnExprTable === null && column.expr.type === 'column_ref') {
 | 
			
		||||
              columnExprTable = from[0].table;
 | 
			
		||||
            } else {
 | 
			
		||||
              const findAs = from.find((from) => from.as === columnExprTable);
 | 
			
		||||
 | 
			
		||||
              if (findAs) {
 | 
			
		||||
                columnExprTable = findAs.table;
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return columnUsage.column_name === column.expr.column && columnUsage.table_name === columnExprTable;
 | 
			
		||||
          });
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user