0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Cleanup (fixing tests)

This commit is contained in:
Roland Bock 2024-08-30 14:25:58 +02:00
parent cf4af171fd
commit 52ca3b6036
14 changed files with 27 additions and 23 deletions

View File

@ -83,7 +83,7 @@ namespace sqlpp
using type = static_combined_check_t<
static_check_t<not is_pre_join_t<Table>::value, assert_from_not_pre_join_t>,
static_check_t<is_table<Table>::value, assert_from_table_t>,
static_check_t<required_tables_of_t<Table>::size::value == 0, assert_from_dependency_free_t>
static_check_t<required_tables_of_t<Table>::empty(), assert_from_dependency_free_t>
>;
};

View File

@ -75,7 +75,7 @@ namespace sqlpp
_data_t _data;
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<group_by_t>::value,
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<group_by_t>,
consistent_t,
assert_no_unknown_tables_in_group_by_t>::type;
};

View File

@ -78,7 +78,7 @@ namespace sqlpp
_data_t _data;
using _table_check = typename std::conditional<Policies::template _no_unknown_tables<having_t>::value,
using _table_check = typename std::conditional<Policies::template _no_unknown_tables<having_t>,
consistent_t,
assert_having_no_unknown_tables_t>::type;

View File

@ -202,7 +202,7 @@ namespace sqlpp
_data_t _data;
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<insert_list_t>::value,
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<insert_list_t>,
consistent_t,
assert_no_unknown_tables_in_insert_assignments_t>::type;
};
@ -282,7 +282,7 @@ namespace sqlpp
void _add_impl(const std::false_type& /*unused*/, Assignments... /*unused*/);
public:
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<column_list_t>::value,
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<column_list_t>,
consistent_t,
assert_no_unknown_tables_in_column_list_t>::type;
};

View File

@ -75,7 +75,7 @@ namespace sqlpp
_data_t _data;
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<order_by_t>::value,
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<order_by_t>,
consistent_t,
assert_no_unknown_tables_in_order_by_t>::type;
};

View File

@ -132,7 +132,7 @@ namespace sqlpp
return *this;
}
using _table_check = typename std::conditional<Policies::template _no_unknown_tables<select_column_list_t>::value,
using _table_check = typename std::conditional<Policies::template _no_unknown_tables<select_column_list_t>,
consistent_t,
assert_no_unknown_tables_in_selected_columns_t>::type;

View File

@ -73,7 +73,7 @@ namespace sqlpp
_data_t _data;
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<update_list_t>::value,
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<update_list_t>,
consistent_t,
assert_no_unknown_tables_in_update_assignments_t>::type;
};

View File

@ -65,7 +65,7 @@ namespace sqlpp
_data_t _data;
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<where_t>::value,
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<where_t>,
consistent_t,
assert_no_unknown_tables_in_where_t>::type;
};

View File

@ -48,6 +48,12 @@ namespace sqlpp
return ::sqlpp::logic::all<contains<X>()...>::value;
}
template <typename... X>
static constexpr bool contains_any(type_vector<X...>)
{
return ::sqlpp::logic::any<contains<X>()...>::value;
}
template <typename... X>
static constexpr bool contains_none(type_vector<X...>)
{

View File

@ -77,13 +77,12 @@ namespace sqlpp
struct make_field_spec_impl
{
using ValueType = select_column_value_type_of_t<NamedExpr>;
static constexpr bool _depends_on_outer_table =
detail::make_intersect_set_t<required_tables_of_t<NamedExpr>,
typename Select::_used_outer_tables>::size::value > 0;
static constexpr bool _depends_on_optional_table =
Select::_used_optional_tables::contains_any(required_tables_of_t<NamedExpr>{});
using type = field_spec_t<
select_column_name_tag_of_t<NamedExpr>,
typename std::conditional<_depends_on_outer_table, sqlpp::force_optional_t<ValueType>, ValueType>::type>;
typename std::conditional<_depends_on_optional_table, sqlpp::force_optional_t<ValueType>, ValueType>::type>;
};
} // namespace detail

View File

@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <type_traits>
#include <sqlpp11/core/type_traits.h>
#include <sqlpp11/core/to_sql_string.h>
namespace sqlpp
{

View File

@ -79,14 +79,11 @@ namespace sqlpp
using _all_provided_ctes = detail::make_joined_set_t<provided_ctes_of<Policies>...>;
using _all_required_tables = detail::type_vector_cat_t<required_tables_of_t<Policies>...>;
using _all_provided_tables = detail::type_vector_cat_t<provided_tables_of_t<Policies>...>;
//using _all_provided_outer_tables = detail::make_joined_set_t<provided_optional_tables_of_t<Policies>...>;
using _all_provided_optional_tables = detail::type_vector_cat_t<provided_optional_tables_of_t<Policies>...>;
using _all_provided_aggregates = detail::make_joined_set_t<provided_aggregates_of<Policies>...>;
#warning reactivate
/*
template <typename Expression>
using _no_unknown_tables = detail::is_subset_of<required_tables_of_t<Expression>, _all_provided_tables>;
*/
static constexpr bool _no_unknown_tables = _all_provided_tables::contains_all(required_tables_of_t<Expression>{});
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2086629
// template <typename... Expressions>
@ -144,7 +141,7 @@ namespace sqlpp
/*
using _can_be_null = logic::any<can_be_null_t<_result_type_provider>::value,
detail::make_intersect_set_t<required_tables_of_t<_result_type_provider>,
_all_provided_outer_tables>::size::value != 0>;
_all_provided_optional_tables>::size::value != 0>;
*/
using _parameters = detail::type_vector_cat_t<parameters_of<Policies>...>;
// required_tables and _required_ctes are defined above
@ -211,7 +208,8 @@ namespace sqlpp
>;
using _name_tag_of = name_tag_of<_result_type_provider>;
using _nodes = detail::type_vector<_policies_t>;
//using _used_outer_tables = typename _policies_t::_all_provided_outer_tables;
#warning: This is an odd name, why "used"?
using _used_optional_tables = typename _policies_t::_all_provided_optional_tables;
// Constructors
statement_t() = default;

View File

@ -112,7 +112,7 @@ namespace sqlpp
// Checks
using _table_check =
typename std::conditional<Policies::template _no_unknown_tables<returning_column_list_t>::value,
typename std::conditional<Policies::template _no_unknown_tables<returning_column_list_t>,
consistent_t,
assert_no_unknown_tables_in_returning_columns_t>::type;

View File

@ -43,12 +43,12 @@ int main(int, char* [])
SQLPP_COMPARE(dynamic(true, val).as(v), "17 AS v");
SQLPP_COMPARE(dynamic(true, expr).as(v), "(17 + 4) AS v");
SQLPP_COMPARE(dynamic(true, count(val)).as(v), "COUNT(17) AS v");
SQLPP_COMPARE(dynamic(true, col.id).as(v), "tab_foo.id AS v");
SQLPP_COMPARE(dynamic(true, col_id).as(v), "tab_foo.id AS v");
SQLPP_COMPARE(dynamic(false, val).as(v), "NULL AS v");
SQLPP_COMPARE(dynamic(false, expr).as(v), "NULL AS v");
SQLPP_COMPARE(dynamic(false, count(val)).as(v), "NULL AS v");
SQLPP_COMPARE(dynamic(false, col.id).as(v), "NULL AS v");
SQLPP_COMPARE(dynamic(false, col_id).as(v), "NULL AS v");
return 0;
}