From 52ca3b60368caa60fc2f4c49494df19b9914f276 Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Fri, 30 Aug 2024 14:25:58 +0200 Subject: [PATCH] Cleanup (fixing tests) --- include/sqlpp11/core/clause/from.h | 2 +- include/sqlpp11/core/clause/group_by.h | 2 +- include/sqlpp11/core/clause/having.h | 2 +- include/sqlpp11/core/clause/insert_value_list.h | 4 ++-- include/sqlpp11/core/clause/order_by.h | 2 +- include/sqlpp11/core/clause/select_column_list.h | 2 +- include/sqlpp11/core/clause/update_list.h | 2 +- include/sqlpp11/core/clause/where.h | 2 +- include/sqlpp11/core/detail/type_vector.h | 6 ++++++ include/sqlpp11/core/field_spec.h | 7 +++---- include/sqlpp11/core/operator/as_expression.h | 1 + include/sqlpp11/core/query/statement.h | 12 +++++------- include/sqlpp11/postgresql/returning_column_list.h | 2 +- tests/core/serialize/operator/as_expression.cpp | 4 ++-- 14 files changed, 27 insertions(+), 23 deletions(-) diff --git a/include/sqlpp11/core/clause/from.h b/include/sqlpp11/core/clause/from.h index a58ac405..890582d3 100644 --- a/include/sqlpp11/core/clause/from.h +++ b/include/sqlpp11/core/clause/from.h @@ -83,7 +83,7 @@ namespace sqlpp using type = static_combined_check_t< static_check_t::value, assert_from_not_pre_join_t>, static_check_t::value, assert_from_table_t>, - static_check_t::size::value == 0, assert_from_dependency_free_t> + static_check_t::empty(), assert_from_dependency_free_t> >; }; diff --git a/include/sqlpp11/core/clause/group_by.h b/include/sqlpp11/core/clause/group_by.h index 6cabbf84..69a82591 100644 --- a/include/sqlpp11/core/clause/group_by.h +++ b/include/sqlpp11/core/clause/group_by.h @@ -75,7 +75,7 @@ namespace sqlpp _data_t _data; - using _consistency_check = typename std::conditional::value, + using _consistency_check = typename std::conditional, consistent_t, assert_no_unknown_tables_in_group_by_t>::type; }; diff --git a/include/sqlpp11/core/clause/having.h b/include/sqlpp11/core/clause/having.h index 214799c4..0b682165 100644 --- a/include/sqlpp11/core/clause/having.h +++ b/include/sqlpp11/core/clause/having.h @@ -78,7 +78,7 @@ namespace sqlpp _data_t _data; - using _table_check = typename std::conditional::value, + using _table_check = typename std::conditional, consistent_t, assert_having_no_unknown_tables_t>::type; diff --git a/include/sqlpp11/core/clause/insert_value_list.h b/include/sqlpp11/core/clause/insert_value_list.h index 90831ec2..36e4348d 100644 --- a/include/sqlpp11/core/clause/insert_value_list.h +++ b/include/sqlpp11/core/clause/insert_value_list.h @@ -202,7 +202,7 @@ namespace sqlpp _data_t _data; - using _consistency_check = typename std::conditional::value, + using _consistency_check = typename std::conditional, 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::value, + using _consistency_check = typename std::conditional, consistent_t, assert_no_unknown_tables_in_column_list_t>::type; }; diff --git a/include/sqlpp11/core/clause/order_by.h b/include/sqlpp11/core/clause/order_by.h index a62e5107..33190dce 100644 --- a/include/sqlpp11/core/clause/order_by.h +++ b/include/sqlpp11/core/clause/order_by.h @@ -75,7 +75,7 @@ namespace sqlpp _data_t _data; - using _consistency_check = typename std::conditional::value, + using _consistency_check = typename std::conditional, consistent_t, assert_no_unknown_tables_in_order_by_t>::type; }; diff --git a/include/sqlpp11/core/clause/select_column_list.h b/include/sqlpp11/core/clause/select_column_list.h index 6a5daf32..9f299312 100644 --- a/include/sqlpp11/core/clause/select_column_list.h +++ b/include/sqlpp11/core/clause/select_column_list.h @@ -132,7 +132,7 @@ namespace sqlpp return *this; } - using _table_check = typename std::conditional::value, + using _table_check = typename std::conditional, consistent_t, assert_no_unknown_tables_in_selected_columns_t>::type; diff --git a/include/sqlpp11/core/clause/update_list.h b/include/sqlpp11/core/clause/update_list.h index c8eb3a92..941488a8 100644 --- a/include/sqlpp11/core/clause/update_list.h +++ b/include/sqlpp11/core/clause/update_list.h @@ -73,7 +73,7 @@ namespace sqlpp _data_t _data; - using _consistency_check = typename std::conditional::value, + using _consistency_check = typename std::conditional, consistent_t, assert_no_unknown_tables_in_update_assignments_t>::type; }; diff --git a/include/sqlpp11/core/clause/where.h b/include/sqlpp11/core/clause/where.h index 7b066b1f..f3f4826a 100644 --- a/include/sqlpp11/core/clause/where.h +++ b/include/sqlpp11/core/clause/where.h @@ -65,7 +65,7 @@ namespace sqlpp _data_t _data; - using _consistency_check = typename std::conditional::value, + using _consistency_check = typename std::conditional, consistent_t, assert_no_unknown_tables_in_where_t>::type; }; diff --git a/include/sqlpp11/core/detail/type_vector.h b/include/sqlpp11/core/detail/type_vector.h index 4f699940..d492479f 100644 --- a/include/sqlpp11/core/detail/type_vector.h +++ b/include/sqlpp11/core/detail/type_vector.h @@ -48,6 +48,12 @@ namespace sqlpp return ::sqlpp::logic::all()...>::value; } + template + static constexpr bool contains_any(type_vector) + { + return ::sqlpp::logic::any()...>::value; + } + template static constexpr bool contains_none(type_vector) { diff --git a/include/sqlpp11/core/field_spec.h b/include/sqlpp11/core/field_spec.h index cb03c69e..8502bd8e 100644 --- a/include/sqlpp11/core/field_spec.h +++ b/include/sqlpp11/core/field_spec.h @@ -77,13 +77,12 @@ namespace sqlpp struct make_field_spec_impl { using ValueType = select_column_value_type_of_t; - static constexpr bool _depends_on_outer_table = - detail::make_intersect_set_t, - 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{}); using type = field_spec_t< select_column_name_tag_of_t, - typename std::conditional<_depends_on_outer_table, sqlpp::force_optional_t, ValueType>::type>; + typename std::conditional<_depends_on_optional_table, sqlpp::force_optional_t, ValueType>::type>; }; } // namespace detail diff --git a/include/sqlpp11/core/operator/as_expression.h b/include/sqlpp11/core/operator/as_expression.h index 8c8dad83..a50e4c87 100644 --- a/include/sqlpp11/core/operator/as_expression.h +++ b/include/sqlpp11/core/operator/as_expression.h @@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include namespace sqlpp { diff --git a/include/sqlpp11/core/query/statement.h b/include/sqlpp11/core/query/statement.h index 3af5b9d8..a74b2f2b 100644 --- a/include/sqlpp11/core/query/statement.h +++ b/include/sqlpp11/core/query/statement.h @@ -79,14 +79,11 @@ namespace sqlpp using _all_provided_ctes = detail::make_joined_set_t...>; using _all_required_tables = detail::type_vector_cat_t...>; using _all_provided_tables = detail::type_vector_cat_t...>; - //using _all_provided_outer_tables = detail::make_joined_set_t...>; + using _all_provided_optional_tables = detail::type_vector_cat_t...>; using _all_provided_aggregates = detail::make_joined_set_t...>; -#warning reactivate - /* template - using _no_unknown_tables = detail::is_subset_of, _all_provided_tables>; - */ + static constexpr bool _no_unknown_tables = _all_provided_tables::contains_all(required_tables_of_t{}); // workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2086629 // template @@ -144,7 +141,7 @@ namespace sqlpp /* using _can_be_null = logic::any::value, detail::make_intersect_set_t, - _all_provided_outer_tables>::size::value != 0>; + _all_provided_optional_tables>::size::value != 0>; */ using _parameters = detail::type_vector_cat_t...>; // 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; diff --git a/include/sqlpp11/postgresql/returning_column_list.h b/include/sqlpp11/postgresql/returning_column_list.h index ad2ff468..f524366f 100644 --- a/include/sqlpp11/postgresql/returning_column_list.h +++ b/include/sqlpp11/postgresql/returning_column_list.h @@ -112,7 +112,7 @@ namespace sqlpp // Checks using _table_check = - typename std::conditional::value, + typename std::conditional, consistent_t, assert_no_unknown_tables_in_returning_columns_t>::type; diff --git a/tests/core/serialize/operator/as_expression.cpp b/tests/core/serialize/operator/as_expression.cpp index 7330915f..a2000021 100644 --- a/tests/core/serialize/operator/as_expression.cpp +++ b/tests/core/serialize/operator/as_expression.cpp @@ -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; }