@@ -31,6 +31,9 @@ struct Employee {
3131 std::string fax;
3232 std::string email;
3333};
34+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
35+ inline constexpr sqlite_orm::orm_table_reference auto employee = sqlite_orm::c<Employee>();
36+ #endif
3437
3538/* *
3639 * This is how custom alias is made:
@@ -208,9 +211,10 @@ int main() {
208211 // ON m.ReportsTo = employees.EmployeeId
209212#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
210213 constexpr orm_table_alias auto m = " m" _alias.for_ <Employee>();
211- auto firstNames = storage.select (columns (m->*&Employee::firstName || " " || m->*&Employee::lastName,
212- &Employee::firstName || " " || &Employee::lastName),
213- inner_join<m>(on (m->*&Employee::reportsTo == &Employee::employeeId)));
214+ auto firstNames =
215+ storage.select (columns (m->*&Employee::firstName || " " || m->*&Employee::lastName,
216+ employee->*&Employee::firstName || " " || employee->*&Employee::lastName),
217+ inner_join<m>(on (m->*&Employee::reportsTo == employee->*&Employee::employeeId)));
214218 cout << " firstNames count = " << firstNames.size () << endl;
215219 for (auto & row: firstNames) {
216220 cout << std::get<0 >(row) << ' \t ' << std::get<1 >(row) << endl;
@@ -219,7 +223,7 @@ int main() {
219223 using als = alias_m<Employee>;
220224 auto firstNames = storage.select (
221225 columns (alias_column<als>(&Employee::firstName) || " " || alias_column<als>(&Employee::lastName),
222- &Employee::firstName || " " || &Employee::lastName),
226+ &Employee::firstName || c ( " " ) || &Employee::lastName),
223227 inner_join<als>(on (alias_column<als>(&Employee::reportsTo) == &Employee::employeeId)));
224228 cout << " firstNames count = " << firstNames.size () << endl;
225229 for (auto & row: firstNames) {
@@ -240,9 +244,10 @@ int main() {
240244#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
241245 static_assert (std::is_empty_v<custom_alias<Employee>>);
242246 constexpr orm_table_alias auto emp = custom_alias<Employee>{};
243- auto firstNames = storage.select (columns (emp->*&Employee::firstName || " " || emp->*&Employee::lastName,
244- &Employee::firstName || " " || &Employee::lastName),
245- inner_join<emp>(on (emp->*&Employee::reportsTo == &Employee::employeeId)));
247+ auto firstNames =
248+ storage.select (columns (emp->*&Employee::firstName || " " || emp->*&Employee::lastName,
249+ employee->*&Employee::firstName || " " || employee->*&Employee::lastName),
250+ inner_join<emp>(on (emp->*&Employee::reportsTo == employee->*&Employee::employeeId)));
246251 cout << " firstNames count = " << firstNames.size () << endl;
247252 for (auto & row: firstNames) {
248253 cout << std::get<0 >(row) << ' \t ' << std::get<1 >(row) << endl;
@@ -251,7 +256,7 @@ int main() {
251256 using als = custom_alias<Employee>;
252257 auto firstNames = storage.select (
253258 columns (alias_column<als>(&Employee::firstName) || " " || alias_column<als>(&Employee::lastName),
254- &Employee::firstName || " " || &Employee::lastName),
259+ &Employee::firstName || c ( " " ) || &Employee::lastName),
255260 inner_join<als>(on (alias_column<als>(&Employee::reportsTo) == &Employee::employeeId)));
256261 cout << " firstNames count = " << firstNames.size () << endl;
257262 for (auto & row: firstNames) {
0 commit comments