Table alias Problem
I have a problem with table alias.
`Table table1 = new Table("mytable1"); table1.setAlias(new Alias("tab1"));
Table table2 = new Table("mytable2");
table2.setAlias(new Alias("tab2"));
List<Expression> colunas = Arrays.asList(new Column(table1, "col1"), new Column(table1, "col2"), new Column(table1, "col3"), new Column(table2, "b1"), new Column(table2, "b2"));
Select select = SelectUtils.buildSelectFromTableAndExpressions(table1, colunas.toArray(new Expression[colunas.size()]));
final EqualsTo equalsTo = new EqualsTo();
equalsTo.setLeftExpression(new Column(table1, "col1"));
equalsTo.setRightExpression(new Column(table2, "b1"));
Join addJoin = SelectUtils.addJoin(select, table2, equalsTo);
addJoin.setLeft(true);
System.out.println( select.toString() );`
The result is:
SELECT mytable1.col1, mytable1.col2, mytable1.col3, mytable2.b1, mytable2.b2 FROM mytable1 AS tab1 LEFT JOIN mytable2 AS tab2 ON mytable1.col1 = mytable2.b1
Not replaced table alias in column and in left clause.
It was a problem with Column.toString. The deparser did the job already right.
I'm not sure the fix is correct. Because the column's FQN should contain the table name, not its alias. So, perhaps you should fix Column's toString() #332. But the Column's getFullyQualifiedName() should remain as before #311 fix.
Good point. I will look into it.
Good point. I will look into it.