Merge branch 'feature/no_table_check_wrapper' into develop

This commit is contained in:
rbock
2016-03-17 17:44:04 +01:00
18 changed files with 98 additions and 313 deletions

View File

@@ -1,220 +0,0 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_EXTRA_TABLES_H
#define SQLPP_EXTRA_TABLES_H
#include <sqlpp11/type_traits.h>
#include <sqlpp11/logic.h>
#include <sqlpp11/policy_update.h>
namespace sqlpp
{
template <typename... Tables>
struct extra_tables_data_t
{
extra_tables_data_t()
{
}
extra_tables_data_t(const extra_tables_data_t&) = default;
extra_tables_data_t(extra_tables_data_t&&) = default;
extra_tables_data_t& operator=(const extra_tables_data_t&) = default;
extra_tables_data_t& operator=(extra_tables_data_t&&) = default;
~extra_tables_data_t() = default;
};
// EXTRA_TABLES
template <typename... Tables>
struct extra_tables_t
{
using _traits = make_traits<no_value_t, tag::is_extra_tables>;
using _nodes = detail::type_vector<>;
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Tables>...>;
using _extra_tables = detail::type_set<Tables...>;
// Data
using _data_t = extra_tables_data_t<Tables...>;
// Member implementation with data and methods
template <typename Policies>
struct _impl_t
{
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2091069
_impl_t() = default;
_impl_t(const _data_t& data) : _data(data)
{
}
_data_t _data;
};
// Base template to be inherited by the statement
template <typename Policies>
struct _base_t
{
using _data_t = extra_tables_data_t<Tables...>;
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2091069
template <typename... Args>
_base_t(Args&&... args)
: extra_tables{std::forward<Args>(args)...}
{
}
_impl_t<Policies> extra_tables;
_impl_t<Policies>& operator()()
{
return extra_tables;
}
const _impl_t<Policies>& operator()() const
{
return extra_tables;
}
template <typename T>
static auto _get_member(T t) -> decltype(t.extra_tables)
{
return t.extra_tables;
}
using _consistency_check = consistent_t;
};
};
// NO EXTRA TABLES YET
struct no_extra_tables_t
{
using _traits = make_traits<no_value_t, tag::is_noop>;
using _nodes = detail::type_vector<>;
// Data
using _data_t = no_data_t;
// Member implementation with data and methods
template <typename Policies>
struct _impl_t
{
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2091069
_impl_t() = default;
_impl_t(const _data_t& data) : _data(data)
{
}
_data_t _data;
};
// Base template to be inherited by the statement
template <typename Policies>
struct _base_t
{
using _data_t = no_data_t;
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2091069
template <typename... Args>
_base_t(Args&&... args)
: no_extra_tables{std::forward<Args>(args)...}
{
}
_impl_t<Policies> no_extra_tables;
_impl_t<Policies>& operator()()
{
return no_extra_tables;
}
const _impl_t<Policies>& operator()() const
{
return no_extra_tables;
}
template <typename T>
static auto _get_member(T t) -> decltype(t.no_extra_tables)
{
return t.no_extra_tables;
}
template <typename Check, typename T>
using _new_statement_t = new_statement_t<Check::value, Policies, no_extra_tables_t, T>;
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269
// template <typename... T>
// using _check = logic::all_t<is_table_t<T>::value...>;
template <typename... T>
struct _check : logic::all_t<is_table_t<T>::value...>
{
};
using _consistency_check = consistent_t;
template <typename... Tables>
auto extra_tables(Tables... tables) const -> _new_statement_t<_check<Tables...>, extra_tables_t<Tables...>>
{
static_assert(_check<Tables...>::value, "at least one argument is not a table or join in extra_tables()");
return _extra_tables_impl<void>(_check<Tables...>{}, tables...);
}
private:
template <typename Database, typename... Tables>
auto _extra_tables_impl(const std::false_type&, Tables... tables) const -> bad_statement;
template <typename Database, typename... Tables>
auto _extra_tables_impl(const std::true_type&, Tables...) const
-> _new_statement_t<std::true_type, extra_tables_t<Tables...>>
{
static_assert(required_tables_of<extra_tables_t<Tables...>>::size::value == 0,
"at least one table depends on another table in extra_tables()");
static constexpr std::size_t _number_of_tables = detail::sum(provided_tables_of<Tables>::size::value...);
using _unique_tables = detail::make_joined_set_t<provided_tables_of<Tables>...>;
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/feedback/details/2173198
// using _unique_table_names = detail::transform_set_t<name_of, _unique_tables>;
using _unique_table_names = detail::make_name_of_set_t<_unique_tables>;
static_assert(_number_of_tables == _unique_tables::size::value,
"at least one duplicate table detected in extra_tables()");
static_assert(_number_of_tables == _unique_table_names::size::value,
"at least one duplicate table name detected in extra_tables()");
return {static_cast<const derived_statement_t<Policies>&>(*this), extra_tables_data_t<Tables...>{}};
}
};
};
// Interpreters
template <typename Context, typename Database, typename... Tables>
struct serializer_t<Context, extra_tables_data_t<Database, Tables...>>
{
using _serialize_check = serialize_check_of<Context, Tables...>;
using T = extra_tables_data_t<Database, Tables...>;
static Context& _(const T&, Context& context)
{
return context;
}
};
}
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -85,17 +85,11 @@ namespace sqlpp
}
template <typename Expression>
void add_ntc(Expression expression)
{
add<Expression, std::false_type>(expression);
}
template <typename Expression, typename TableCheckRequired = std::true_type>
void add(Expression expression)
{
static_assert(_is_dynamic::value, "add() must not be called for static group_by");
static_assert(is_expression_t<Expression>::value, "invalid expression argument in group_by::add()");
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value,
static_assert(Policies::template _no_unknown_tables<Expression>::value,
"expression uses tables unknown to this statement in group_by::add()");
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expression>;
_serialize_check::_();

View File

@@ -82,17 +82,11 @@ namespace sqlpp
}
template <typename Expr>
void add_ntc(Expr expression)
{
add<Expr, std::false_type>(expression);
}
template <typename Expr, typename TableCheckRequired = std::true_type>
void add(Expr expression)
{
static_assert(_is_dynamic::value, "having::add() can only be called for dynamic_having");
static_assert(is_expression_t<Expr>::value, "invalid expression argument in having::add()");
static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables<Expr>::value,
static_assert(Policies::template _no_unknown_tables<Expr>::value,
"expression uses tables unknown to this statement in having::add()");
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expr>;
_serialize_check::_();

View File

@@ -252,12 +252,6 @@ namespace sqlpp
}
template <typename Assignment>
void add_ntc(Assignment assignment)
{
add<Assignment, std::false_type>(assignment);
}
template <typename Assignment, typename TableCheckRequired = std::true_type>
void add(Assignment assignment)
{
static_assert(_is_dynamic::value, "add must not be called for static from()");
@@ -266,7 +260,7 @@ namespace sqlpp
static_assert(not detail::is_element_of<lhs_t<Assignment>, _assigned_columns>::value,
"Must not assign value to column twice");
static_assert(not must_not_insert_t<lhs_t<Assignment>>::value, "add() argument must not be used in insert");
static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables<Assignment>::value,
static_assert(Policies::template _no_unknown_tables<Assignment>::value,
"add() contains a column from a foreign table");
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Assignment>;
_serialize_check::_();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -82,17 +82,11 @@ namespace sqlpp
}
template <typename Expression>
void add_ntc(Expression expression)
{
add<Expression, std::false_type>(expression);
}
template <typename Expression, typename TableCheckRequired = std::true_type>
void add(Expression expression)
{
static_assert(_is_dynamic::value, "add() must not be called for static order_by");
static_assert(is_sort_order_t<Expression>::value, "invalid expression argument in order_by::add()");
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value,
static_assert(Policies::template _no_unknown_tables<Expression>::value,
"expression uses tables unknown to this statement in order_by::add()");
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expression>;
_serialize_check::_();

View File

@@ -34,7 +34,6 @@
#include <sqlpp11/prepared_remove.h>
#include <sqlpp11/noop.h>
#include <sqlpp11/from.h>
#include <sqlpp11/extra_tables.h>
#include <sqlpp11/using.h>
#include <sqlpp11/where.h>
@@ -103,7 +102,7 @@ namespace sqlpp
};
template <typename Database>
using blank_remove_t = statement_t<Database, remove_t, no_from_t, no_using_t, no_extra_tables_t, no_where_t<true>>;
using blank_remove_t = statement_t<Database, remove_t, no_from_t, no_using_t, no_where_t<true>>;
inline auto remove() -> blank_remove_t<void>
{

View File

@@ -35,7 +35,6 @@
#include <sqlpp11/select_flag_list.h>
#include <sqlpp11/select_column_list.h>
#include <sqlpp11/from.h>
#include <sqlpp11/extra_tables.h>
#include <sqlpp11/where.h>
#include <sqlpp11/group_by.h>
#include <sqlpp11/having.h>
@@ -77,7 +76,6 @@ namespace sqlpp
no_select_flag_list_t,
no_select_column_list_t,
no_from_t,
no_extra_tables_t,
no_where_t<true>,
no_group_by_t,
no_having_t,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -123,19 +123,13 @@ namespace sqlpp
}
template <typename NamedExpression>
void add_ntc(NamedExpression namedExpression)
{
add<NamedExpression, std::false_type>(namedExpression);
}
template <typename NamedExpression, typename TableCheckRequired = std::true_type>
void add(NamedExpression namedExpression)
{
using named_expression = auto_alias_t<NamedExpression>;
static_assert(_is_dynamic::value, "selected_columns::add() can only be called for dynamic_column");
static_assert(is_selectable_t<named_expression>::value,
"invalid named expression argument in selected_columns::add()");
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<named_expression>::value,
static_assert(Policies::template _no_unknown_tables<named_expression>::value,
"named expression uses tables unknown to this statement in selected_columns::add()");
using column_names = detail::make_type_set_t<typename Columns::_alias_t...>;
static_assert(not detail::is_element_of<typename named_expression::_alias_t, column_names>::value,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -78,17 +78,11 @@ namespace sqlpp
}
template <typename Flag>
void add_ntc(Flag flag)
{
add<Flag, std::false_type>(flag);
}
template <typename Flag, typename TableCheckRequired = std::true_type>
void add(Flag flag)
{
static_assert(_is_dynamic::value, "select_flags::add() must not be called for static select flags");
static_assert(is_select_flag_t<Flag>::value, "invalid select flag argument in select_flags::add()");
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Flag>::value,
static_assert(Policies::template _no_unknown_tables<Flag>::value,
"flag uses tables unknown to this statement in select_flags::add()");
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Flag>;
_serialize_check::_();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -36,6 +36,7 @@
#include <sqlpp11/functions.h>
#include <sqlpp11/transaction.h>
#include <sqlpp11/boolean_expression.h>
#include <sqlpp11/without_table_check.h>
#include <sqlpp11/schema_qualified_table.h>
#endif

View File

@@ -76,13 +76,10 @@ namespace sqlpp
using _all_required_tables = detail::make_joined_set_t<required_tables_of<Policies>...>;
using _all_provided_tables = detail::make_joined_set_t<provided_tables_of<Policies>...>;
using _all_provided_outer_tables = detail::make_joined_set_t<provided_outer_tables_of<Policies>...>;
using _all_extra_tables = detail::make_joined_set_t<extra_tables_of<Policies>...>;
using _all_provided_aggregates = detail::make_joined_set_t<provided_aggregates_of<Policies>...>;
using _known_tables = detail::make_joined_set_t<_all_provided_tables, _all_extra_tables>;
template <typename Expression>
using _no_unknown_tables = detail::is_subset_of<required_tables_of<Expression>, _known_tables>;
using _no_unknown_tables = detail::is_subset_of<required_tables_of<Expression>, _all_provided_tables>;
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2086629
// template <typename... Expressions>
@@ -100,11 +97,7 @@ namespace sqlpp
using any_t = logic::any_t<Predicate<Policies>::value...>;
// The tables not covered by the from.
using _required_tables =
detail::make_difference_set_t<_all_required_tables,
_all_provided_tables // Hint: extra_tables are not used here because they are
// just a helper for dynamic .add_*()
>;
using _required_tables = detail::make_difference_set_t<_all_required_tables, _all_provided_tables>;
// The common table expressions not covered by the with.
using _required_ctes = detail::make_difference_set_t<_all_required_ctes, _all_provided_ctes>;

View File

@@ -181,7 +181,6 @@ namespace sqlpp
SQLPP_VALUE_TRAIT_GENERATOR(is_from)
SQLPP_VALUE_TRAIT_GENERATOR(is_single_table)
SQLPP_VALUE_TRAIT_GENERATOR(is_into)
SQLPP_VALUE_TRAIT_GENERATOR(is_extra_tables)
SQLPP_VALUE_TRAIT_GENERATOR(is_on)
SQLPP_VALUE_TRAIT_GENERATOR(is_where)
SQLPP_VALUE_TRAIT_GENERATOR(is_group_by)
@@ -259,7 +258,6 @@ namespace sqlpp
SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(required_tables)
SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(provided_tables)
SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(provided_outer_tables)
SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(extra_tables)
SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(provided_aggregates)
#define SQLPP_RECURSIVE_TRAIT_GENERATOR(trait) \

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -78,12 +78,6 @@ namespace sqlpp
}
template <typename Assignment>
void add_ntc(Assignment assignment)
{
add<Assignment, std::false_type>(assignment);
}
template <typename Assignment, typename TableCheckRequired = std::true_type>
void add(Assignment assignment)
{
static_assert(_is_dynamic::value, "add must not be called for static from()");
@@ -92,7 +86,7 @@ namespace sqlpp
static_assert(not detail::is_element_of<lhs_t<Assignment>, _assigned_columns>::value,
"Must not assign value to column twice");
static_assert(logic::not_t<must_not_update_t, lhs_t<Assignment>>::value, "add() argument must not be updated");
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Assignment>::value,
static_assert(Policies::template _no_unknown_tables<Assignment>::value,
"assignment uses tables unknown to this statement in add()");
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Assignment>;
_serialize_check::_();

View File

@@ -84,18 +84,12 @@ namespace sqlpp
}
template <typename Expr>
void add_ntc(Expr expression)
{
add<Expr, std::false_type>(expression);
}
template <typename Expr, typename TableCheckRequired = std::true_type>
void add(Expr expression)
{
static_assert(_is_dynamic::value, "where::add() can only be called for dynamic_where");
static_assert(is_expression_t<Expr>::value, "invalid expression argument in where::add()");
static_assert(is_boolean_t<Expr>::value, "invalid expression argument in where::add()");
static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables<Expr>::value,
static_assert(Policies::template _no_unknown_tables<Expr>::value,
"expression uses tables unknown to this statement in where::add()");
static_assert(not contains_aggregate_function_t<Expr>::value,
"where expression must not contain aggregate functions");

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2016-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* 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>
namespace sqlpp
{
template <typename Expression>
struct without_table_check_t : Expression
{
using _required_tables = detail::type_set<>;
without_table_check_t(Expression expression) : Expression(expression)
{
}
};
template <typename Context, typename Expression>
struct serializer_t<Context, without_table_check_t<Expression>>
{
using _serialize_check = serialize_check_of<Context, Expression>;
using T = without_table_check_t<Expression>;
static Context& _(const T& t, Context& context)
{
serialize<Expression>(t, context);
return context;
}
};
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)");
return {expr};
}
}
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -163,13 +163,11 @@ int Interpret(int, char* [])
serialize(s, printer).str();
}
{
auto s = dynamic_select(db)
.dynamic_flags(sqlpp::distinct)
.dynamic_columns(t.alpha)
.extra_tables(t); // Would fail to run()
// Behold, dynamically constructed queries might compile but be illegal SQL
auto s = dynamic_select(db).dynamic_flags(sqlpp::distinct).dynamic_columns(t.alpha);
s.select_flags.add(sqlpp::all);
s.selected_columns.add(t.beta);
s.selected_columns.add(t.gamma);
s.selected_columns.add(without_table_check(t.beta));
s.selected_columns.add(without_table_check(t.gamma));
serialize(s, printer).str();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -31,6 +31,7 @@
#include <sqlpp11/select.h>
#include <sqlpp11/functions.h>
#include <sqlpp11/connection.h>
#include <sqlpp11/without_table_check.h>
template <typename Db, typename Column>
int64_t getColumn(Db&& db, const Column& column)
@@ -108,7 +109,6 @@ int Select(int, char* [])
.columns(all_of(t))
.flags(sqlpp::all)
.from(t)
.extra_tables(f, t)
.where(t.alpha > 0)
.group_by(t.alpha)
.order_by(t.gamma.asc())
@@ -122,7 +122,6 @@ int Select(int, char* [])
.columns(all_of(t))
.flags(sqlpp::all)
.from(t)
.extra_tables(f, t)
.where(t.alpha > 0)
.group_by(t.alpha)
.order_by(t.gamma.asc())
@@ -137,7 +136,6 @@ int Select(int, char* [])
.dynamic_columns(all_of(t))
.dynamic_flags()
.dynamic_from(t)
.extra_tables(f, t)
.dynamic_where()
.dynamic_group_by(t.alpha)
.dynamic_order_by()
@@ -145,7 +143,7 @@ int Select(int, char* [])
.dynamic_limit()
.dynamic_offset();
s.select_flags.add(sqlpp::distinct);
s.selected_columns.add(f.omega);
s.selected_columns.add(without_table_check(f.omega));
s.from.add(dynamic_cross_join(f));
s.where.add(t.alpha > 7);
s.having.add(t.alpha > 7);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2015, Roland Bock
* Copyright (c) 2013-2016, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -31,6 +31,7 @@
#include <sqlpp11/select.h>
#include <sqlpp11/functions.h>
#include <sqlpp11/connection.h>
#include <sqlpp11/without_table_check.h>
namespace alias
{
@@ -327,7 +328,7 @@ int SelectType(int, char* [])
{
auto s = dynamic_select(db, all_of(t)).dynamic_from(t).dynamic_where().dynamic_limit().dynamic_offset();
s.from.add(dynamic_join(f).on(f.omega > t.alpha));
s.where.add_ntc(t.alpha > 7 and t.alpha == any(select(t.alpha).from(t).where(t.alpha < 3)));
s.where.add(without_table_check(f.omega > 7 and t.alpha == any(select(t.alpha).from(t).where(t.alpha < 3))));
s.limit.set(30);
s.limit.set(3);
std::cerr << "------------------------\n";
@@ -339,8 +340,8 @@ int SelectType(int, char* [])
// Test that select can be called with zero columns if it is used with dynamic columns.
{
auto s = dynamic_select(db).dynamic_columns().extra_tables(t);
s.selected_columns.add(t.alpha);
auto s = dynamic_select(db).dynamic_columns();
s.selected_columns.add(without_table_check(t.alpha));
serialize(s, printer).str();
}