Open supermuka opened 4 years ago
Hm, this is especially true if the same table is joined with two alias.
Yes, exactly!
With this query we have problems. But it should work correctly with results below:
List<Map<String, Map<String, dynamic>>> results = await connection.mappedResultsQuery(
"SELECT t_alias.id, t_alias.name, u_alias.name, u_two_alias.name FROM t t_alias
LEFT OUTER JOIN u u_alias ON t_alias.id=u_alias.t_id
LEFT OUTER JOIN u u_two_alias ON t_alias.id_two=u_tow_alias.t_id");
for (final row in results) {
var tID = row["t_alias"]["id"];
var tName = row["t_alias"]["name"];
var uName = row["u_alias"]["name"];
var uTwoName = row["u_two_alias"]["name"];
}
mappedResultsQuery should be mapped to table Alias instead table Name, when has an alias.
Now, this works. But it ignores the alias on the table:
But the correct way should be with alias:
Column name x alias is working correctly. When it has an alias in column, the mappedResultsQuery returns the alias instead column name.