Fix without_table_check for alias expressions

This commit is contained in:
rbock
2017-10-16 20:43:07 +02:00
parent 62e989c8b3
commit f6cb213e55
2 changed files with 8 additions and 6 deletions

View File

@@ -27,9 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_WITHOUT_TABLE_CHECK_H
#define SQLPP_ALIAS_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/serializer.h>
@@ -61,12 +58,11 @@ namespace sqlpp
template <typename Expression>
auto without_table_check(Expression expr) -> without_table_check_t<Expression>
{
static_assert(is_expression_t<Expression>::value, "invalid argument (expression expected)");
static_assert(is_expression_t<Expression>::value or is_alias_t<Expression>::value,
"invalid argument (expression or alias expression expected)");
return {expr};
}
} // namespace sqlpp
#endif
#endif

View File

@@ -396,6 +396,12 @@ int SelectType(int, char* [])
serialize(s, printer).str();
}
{
auto find_query = sqlpp::dynamic_select(db).dynamic_columns(t.alpha.as(alias::a)).dynamic_from(t).unconditionally();
find_query.from.add(sqlpp::dynamic_join(f).on(t.alpha == f.omega));
find_query.selected_columns.add(sqlpp::without_table_check(f.omega.as(alias::b)));
}
// Test that verbatim_table compiles
{
auto s = select(t.alpha).from(sqlpp::verbatim_table("my_unknown_table"));