Allow aliasing columns in aliased relations.
Implement the functionality allowing to alias columns when aliasing a relation (in standard SQL according to https://modern-sql.com/use-case/naming-unnamed-columns):
SELECT t.b, t.a FROM (SELECT 1 AS x, 2 AS x) AS t(a, b);
could be given by:
import querybuilder as qb
from querybuilder.queries.algebra.columns import make_column
q = qb.queries.dql.Select([make_column(1), make_column(2)], aliases={0: "x", 1: "x"}))
qa = q.alias("t", {0: "a", 1: "b"})
qs = qa.select([qa.c.b, qa.c.a])
print(str(qs))
The interface should allow to specify only some of the column aliases, other column being aliased by their original name, e.g.,
qa = q.alias("t", {1: "b"})
print(str(qs))
should give:
(SELECT 1 AS x, 2 AS x) AS t(x, b);
Edited by Bruno Guillon