I need to implement something like
(SELECT table1.*, val=2 FROM table1 INNER JOIN table2 ON table1.id = table2.id WHERE some_condition)
UNION
(SELECT table1.*, val=3 FROM table1 INNER JOIN table3 ON table1.id = table3.id WHERE some_condition)
or
(SELECT val1, val2, val3, val=2 FROM table2 WHERE some_condition)
UNION
(SELECT val1, val2, val3, val=3 FROM table3 WHERE some_condition)
I.e. having the class 'table1', 'table2' and 'table3' where table2 and table3 are derived from table1 I need to select all of them with additional field. The problem is that I'd prefere to avoid using raw sql queries as some_condition should be reusable. If I try to use extra it complains that I use .extra
.