I have the following case classes representing entities:
case class A(id: Long, name: String)
case class B(id: Long, someField: String)
val parser = Macro.namedParser[A] ~ Macro.namedParser[B]
val list = SQL"SELECT a.*, b.* FROM A as a LEFT JOIN B as b on a.id = b.a_id".as(parser.*)
The id
field of A
and B
are identical, even though they are not identical in the database. It seem that the parser uses the last matching column name.
How would you parse rows from a JOIN with multiple column names that clashes? The field id
is probably not the only name clash in real projects.