}
return columns;
}
private Column convert2Column(Sql sql,ResultSetMetaData metadata, int i) throws SQLException, Exception {
ResultSetMetaDataHolder m = new ResultSetMetaDataHolder(metadata, i);
if(StringHelper.isNotBlank(m.getTableName())) {
//FIXME 如果表有别名,将会找不到表,如 inner join user_info t1, tableName将为t1,应该转换为user_info
Table table = foundTableByTableNameOrTableAlias(sql, m.getTableName());
if(table == null) {
return newColumn(null,m);
}
Column column = table.getColumnBySqlName(m.getColumnLabelOrName());
if(column == null || column.getSqlType() != m.getColumnType()) {
//可以再尝试解析sql得到 column以解决 password as pwd找不到column问题
column = newColumn(table,m);
GLogger.trace("not found column:"+m.getColumnLabelOrName()+" on table:"+table.getSqlName()+" "+BeanHelper.describe(column));
//isInSameTable以此种判断为错误
}else {
GLogger.trace("found column:"+m.getColumnLabelOrName()+" on table:"+table.getSqlName()+" "+BeanHelper.describe(column));
}
return column;
}else {
return newColumn(null,m);
}