Closed KuceraMartin closed 1 year ago
could we reuse one macro instead of having 4 different ones?
e.g. use :*
n times to implement ++
-> we seem to lose the information about the generic arguments of NamedExpression in the process :/
overwriting is okay
put a simplified example in the other repo
so far managed to implement with custom replace
function:
def replace(columns: Tuple, name: String, replacement: Expression[_]): Tuple =
columns match
case EmptyTuple => EmptyTuple
case (h: NamedExpression[_, _]) *: t =>
(if (h.alias == name) replacement else h) *: replace(t, name, replacement)
but would be nice if we could just use Tuple.map
or something like that
right now we allow something like
and we translate it as
which is accepted (at least by Postgres) but weird. If we run this in a subquery and try to access name from the outer query, we get
ERROR: column reference "name" is ambiguous
.Solutions:
.map { s => s ++ (...) }