sqlite_orm
sqlite_orm copied to clipboard
Cannot select all columns in a cross join
I can't get all the columns of a cross join like this one: (it does not compile)
storage.select(asterisk<Employee>(), asterisk<Department>, cross_join<Department>());
This one does not compile either although they are semantically equivalent:
storage.select(asterisk<Employee>(), asterisk<Department>());
The error messages are:
dev\statement_serializer.h(56,20): error C2064: term does not evaluate to a function taking 2 arguments
This one compiles but only gives Employee's columns (although it does the cross_join correctly):
storage.select(asterisk<Employee>(), cross_join<Department>());
BTW, this last one produces the correct SQL string:
SELECT * FROM "Emp" CROSS JOIN "Dept"
but does not return the 12 columns it should (the 8 from Employee and the 4 from Dept)
so there is something wrong with the bindings I think (it only returns the 8 cols from Employee)
storage.select(asterisk<Employee>(), asterisk<Department>, cross_join<Department>());
is not correct cause it means SELECT *, * CROSS JOIN ...
.
storage.select(asterisk<Employee>(), asterisk<Department>());
is also not correct cause it means SELECT *, * FROM ...
.
storage.select(asterisk<Employee>(), cross_join<Department>());
this is a bug. It needs to be fixed. It is related to statement_serializer
which doesn't count with select constraints cross_join
. Let's leave this issue opened until the bug is fixed
This is fixed by PR #1143, and is very closely related to Is it possible to write 2 or more asterisks in a select? #1106.
So it is possible to write
select(columns(asterisk<Employee>(), asterisk<Department>()))
or
select(columns(asterisk<Employee>(), asterisk<Department>()),
from<Employee>(),
cross_join<Department>())