@@ -31,6 +31,9 @@ struct Employee {
31
31
std::string fax;
32
32
std::string email;
33
33
};
34
+ #ifdef SQLITE_ORM_WITH_CPP20_ALIASES
35
+ inline constexpr sqlite_orm::orm_table_reference auto employee = sqlite_orm::c<Employee>();
36
+ #endif
34
37
35
38
/* *
36
39
* This is how custom alias is made:
@@ -208,9 +211,10 @@ int main() {
208
211
// ON m.ReportsTo = employees.EmployeeId
209
212
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
210
213
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)));
214
218
cout << " firstNames count = " << firstNames.size () << endl;
215
219
for (auto & row: firstNames) {
216
220
cout << std::get<0 >(row) << ' \t ' << std::get<1 >(row) << endl;
@@ -219,7 +223,7 @@ int main() {
219
223
using als = alias_m<Employee>;
220
224
auto firstNames = storage.select (
221
225
columns (alias_column<als>(&Employee::firstName) || " " || alias_column<als>(&Employee::lastName),
222
- &Employee::firstName || " " || &Employee::lastName),
226
+ &Employee::firstName || c ( " " ) || &Employee::lastName),
223
227
inner_join<als>(on (alias_column<als>(&Employee::reportsTo) == &Employee::employeeId)));
224
228
cout << " firstNames count = " << firstNames.size () << endl;
225
229
for (auto & row: firstNames) {
@@ -240,9 +244,10 @@ int main() {
240
244
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
241
245
static_assert (std::is_empty_v<custom_alias<Employee>>);
242
246
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)));
246
251
cout << " firstNames count = " << firstNames.size () << endl;
247
252
for (auto & row: firstNames) {
248
253
cout << std::get<0 >(row) << ' \t ' << std::get<1 >(row) << endl;
@@ -251,7 +256,7 @@ int main() {
251
256
using als = custom_alias<Employee>;
252
257
auto firstNames = storage.select (
253
258
columns (alias_column<als>(&Employee::firstName) || " " || alias_column<als>(&Employee::lastName),
254
- &Employee::firstName || " " || &Employee::lastName),
259
+ &Employee::firstName || c ( " " ) || &Employee::lastName),
255
260
inner_join<als>(on (alias_column<als>(&Employee::reportsTo) == &Employee::employeeId)));
256
261
cout << " firstNames count = " << firstNames.size () << endl;
257
262
for (auto & row: firstNames) {
0 commit comments