0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Added a few auto alias tests

This commit is contained in:
rbock 2016-12-25 21:25:01 +01:00
parent d06b386e03
commit 5e52a4da46
2 changed files with 8 additions and 1 deletions

View File

@ -44,7 +44,7 @@ namespace sqlpp
template <typename T> template <typename T>
struct _member_t struct _member_t
{ {
T in; T not_in;
}; };
}; };
}; };

View File

@ -44,5 +44,12 @@ int As(int, char* [])
compare(__LINE__, (count(foo.omega) - bar.alpha).as(cheese), "(COUNT(tab_foo.omega)-tab_bar.alpha) AS cheese"); compare(__LINE__, (count(foo.omega) - bar.alpha).as(cheese), "(COUNT(tab_foo.omega)-tab_bar.alpha) AS cheese");
compare(__LINE__, (count(foo.omega) - uint32_t(17)).as(cheese), "(COUNT(tab_foo.omega)-17) AS cheese"); compare(__LINE__, (count(foo.omega) - uint32_t(17)).as(cheese), "(COUNT(tab_foo.omega)-17) AS cheese");
// Auto alias
compare(__LINE__, select(max(bar.alpha)), "SELECT MAX(tab_bar.alpha) AS max_");
compare(__LINE__, select(max(bar.alpha).as(cheese)), "SELECT MAX(tab_bar.alpha) AS cheese");
compare(__LINE__, select(max(bar.alpha)).from(bar).unconditionally().as(cheese),
"(SELECT MAX(tab_bar.alpha) AS max_ FROM tab_bar) AS cheese");
compare(__LINE__, select(max(bar.alpha)).from(bar).unconditionally().as(cheese).max, "cheese.max_");
return 0; return 0;
} }