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

Added verbatim tables to join serialization tests

This commit is contained in:
rbock 2016-03-21 09:05:55 +01:00
parent db2e36cb6e
commit 3be1ca1098

View File

@ -62,6 +62,20 @@ int From(int, char* [])
__LINE__, from(aFoo.join(bFoo).on(aFoo.omega > bFoo.omega).join(cFoo).on(bFoo.omega > cFoo.omega)),
" FROM tab_foo AS a INNER JOIN tab_foo AS b ON (a.omega>b.omega) INNER JOIN tab_foo AS c ON (b.omega>c.omega)");
// Static joins involving verbatim tables
compare(__LINE__, from(aFoo.join(sqlpp::verbatim_table("unknown_table"))
.on(aFoo.omega > sqlpp::verbatim<sqlpp::floating_point>("unknown_table.column_x"))),
" FROM tab_foo AS a INNER JOIN unknown_table ON (a.omega>unknown_table.column_x)");
compare(__LINE__, from(sqlpp::verbatim_table("unknown_table")
.join(aFoo)
.on(aFoo.omega > sqlpp::verbatim<sqlpp::floating_point>("unknown_table.column_x"))),
" FROM unknown_table INNER JOIN tab_foo AS a ON (a.omega>unknown_table.column_x)");
compare(__LINE__, from(sqlpp::verbatim_table("unknown_table")
.as(sqlpp::alias::a)
.join(sqlpp::verbatim_table("another_table"))
.on(sqlpp::verbatim<sqlpp::boolean>("a.column_x>another_table.x"))),
" FROM unknown_table AS a INNER JOIN another_table ON a.column_x>another_table.x");
// Dynamic joins
const auto df = dynamic_from(db, foo);
compare(__LINE__, df, " FROM tab_foo");
@ -103,5 +117,13 @@ int From(int, char* [])
"ON (tab_bar.alpha>a.omega)");
}
// Dynamic joins involving verbatim table
{
auto dfa = df;
dfa.from.add(dynamic_inner_join(sqlpp::verbatim_table("unknown_table"))
.on(bar.alpha > sqlpp::verbatim<sqlpp::floating_point>("unknown_table.column_x")));
compare(__LINE__, dfa, " FROM tab_foo INNER JOIN unknown_table ON (tab_bar.alpha>unknown_table.column_x)");
}
return 0;
}