diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 0977d83c..da6f5b6e 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -86,16 +86,14 @@ namespace sqlpp }; template - struct name_tag_of> - { - using type = typename ColumnSpec::_alias_t; - }; + struct name_tag_of> : public name_tag_of{}; template struct has_default> : public ColumnSpec::has_default { }; +#warning: Do we need this? template struct has_name> : std::true_type { diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 106ea380..290f3b27 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -88,10 +88,11 @@ namespace sqlpp using type = cte_ref_t; }; +#warning: Why can't we use FieldSpec directly? If not, does this one need to inherit from name_tag_base? template struct cte_column_spec_t { - using _alias_t = typename FieldSpec::_alias_t; + using _alias_t = name_tag_of_t; using _traits = make_traits>; }; @@ -155,7 +156,6 @@ namespace sqlpp using _required_ctes = detail::make_joined_set_t, detail::type_set>; using _parameters = parameters_of; - using _alias_t = typename AliasProvider::_alias_t; constexpr static bool _is_recursive = required_ctes_of::template count(); using _column_tuple_t = std::tuple>...>; @@ -240,8 +240,6 @@ namespace sqlpp using _required_ctes = detail::make_type_set_t; using _provided_tables = detail::type_set; - using _alias_t = typename AliasProvider::_alias_t; - template auto as(Statement statement) -> make_cte_t { diff --git a/include/sqlpp11/field_spec.h b/include/sqlpp11/field_spec.h index d4e1e716..e08906ae 100644 --- a/include/sqlpp11/field_spec.h +++ b/include/sqlpp11/field_spec.h @@ -34,6 +34,7 @@ namespace sqlpp { +#warning: Do we need this? It should be possible to use name_tag_of_t and value_type_of_t somehow template struct field_spec_t { diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index a6b09f7e..381a0466 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -111,7 +111,7 @@ namespace sqlpp -> decltype(_columns) { (void)assignments; - return decltype(_columns)(std::get(assignments)._lhs...); + return decltype(_columns)(std::get(assignments)._l...); } auto columns_from_tuple(std::tuple assignments) -> decltype(_columns) @@ -125,7 +125,7 @@ namespace sqlpp -> decltype(_values) { (void)assignments; - return decltype(_values)(std::get(assignments)._rhs...); + return decltype(_values)(std::get(assignments)._r...); } auto values_from_tuple(std::tuple assignments) -> decltype(_values) diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index ef6524d8..f40fd1e6 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -38,8 +38,7 @@ namespace sqlpp template struct check_on { - using type = static_combined_check_t::value, assert_on_is_expression_t>, - static_check_t::value, assert_on_is_boolean_expression_t>>; + using type = static_combined_check_t::value, assert_on_is_boolean_expression_t>>; }; template diff --git a/include/sqlpp11/postgresql/returning_column_list.h b/include/sqlpp11/postgresql/returning_column_list.h index 7bc7feca..e6e4b9de 100644 --- a/include/sqlpp11/postgresql/returning_column_list.h +++ b/include/sqlpp11/postgresql/returning_column_list.h @@ -51,9 +51,6 @@ namespace sqlpp struct returning_traits { using _traits = make_traits; - struct _alias_t - { - }; }; template @@ -64,7 +61,6 @@ namespace sqlpp tag::is_return_value, tag::is_expression, tag::is_selectable>; // TODO: Is this correct? - using _alias_t = typename Column::_alias_t; }; } // namespace detail @@ -96,7 +92,6 @@ namespace sqlpp { using _traits = typename detail::returning_traits::_traits; using _nodes = ::sqlpp::detail::type_vector; - using _alias_t = typename detail::returning_traits::_alias_t; struct _column_type { @@ -157,6 +152,7 @@ namespace sqlpp template using _table_t = typename _deferred_table_t::table; +#warning: review all the alias stuff here template using _alias_t = typename _deferred_table_t::alias; @@ -203,6 +199,16 @@ namespace sqlpp }; }; + template + struct value_type_of> : public value_type_of + { + }; + + template + struct name_tag_of> : public name_tag_of + { + }; + namespace detail { template diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index bc71948b..ac0e11f9 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -35,9 +35,10 @@ namespace sqlpp // // provide type information for sub-selects that are used as named expressions or tables template - struct select_column_spec_t + struct select_column_spec_t: public name_tag_base { using _alias_t = name_tag_of_t; + using has_default = std::false_type; static constexpr bool _depends_on_outer_table = detail::make_intersect_set_t, typename Select::_used_outer_tables>::size::value > diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 90b09caf..f2d57a4d 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -47,6 +47,9 @@ namespace sqlpp using _provided_tables = detail::type_set; static_assert(sizeof...(ColumnSpec) > 0, "at least one column required per table"); + template struct require_insert : std::integral_constant::value>{}; + using _required_insert_columns = + typename detail::make_type_set_if...>::type; using _column_tuple_t = std::tuple...>; template using _foreign_table_alias_t = table_alias_t; @@ -102,7 +105,7 @@ namespace sqlpp template Context& serialize(Context& context, const table_t& /*unused*/) { - context << Table::_alias_t::_name_t::template char_ptr(); + context << name_tag_of_t
::_name_t::template char_ptr(); return context; } } // namespace sqlpp diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 9da41bbb..ab91aa84 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -64,10 +64,6 @@ namespace sqlpp using _traits = make_traits; using _nodes = detail::type_vector; - using _alias_t = struct - { - }; - using _data_t = union_data_t; // Base template to be inherited by the statement diff --git a/include/sqlpp11/verbatim.h b/include/sqlpp11/verbatim.h index 80990fa0..b85fa736 100644 --- a/include/sqlpp11/verbatim.h +++ b/include/sqlpp11/verbatim.h @@ -55,6 +55,12 @@ namespace sqlpp std::string _verbatim; }; + template + struct value_type_of> + { + using type = ValueType; + }; + template Context& serialize(Context& context, const verbatim_t& t) { diff --git a/include/sqlpp11/verbatim_table.h b/include/sqlpp11/verbatim_table.h index b1931593..4a820642 100644 --- a/include/sqlpp11/verbatim_table.h +++ b/include/sqlpp11/verbatim_table.h @@ -48,6 +48,7 @@ namespace sqlpp }; }; using _traits = make_traits; + using has_default = std::false_type; }; } // namespace detail diff --git a/tests/core/serialize/CMakeLists.txt b/tests/core/serialize/CMakeLists.txt index e55ae742..eab643df 100644 --- a/tests/core/serialize/CMakeLists.txt +++ b/tests/core/serialize/CMakeLists.txt @@ -34,9 +34,9 @@ set(test_files Exists.cpp Float.cpp #ForUpdate.cpp - #From.cpp + From.cpp In.cpp - #Insert.cpp + Insert.cpp IsNotNull.cpp IsNull.cpp Lower.cpp @@ -48,7 +48,7 @@ set(test_files SelectColumns.cpp SelectFlags.cpp Sum.cpp - #TableAlias.cpp + TableAlias.cpp Trim.cpp Upper.cpp Where.cpp diff --git a/tests/core/serialize/Insert.cpp b/tests/core/serialize/Insert.cpp index 0561b4e8..131da36d 100644 --- a/tests/core/serialize/Insert.cpp +++ b/tests/core/serialize/Insert.cpp @@ -34,7 +34,7 @@ namespace auto getTrue() -> std::string { MockDb::_serializer_context_t printer = {}; - return serialize(sqlpp::value(true), printer).str(); + return serialize(printer, sqlpp::value(true)).str(); } } @@ -45,7 +45,7 @@ int Insert(int, char* []) compare(__LINE__, insert_into(bar).default_values(), "INSERT INTO tab_bar DEFAULT VALUES"); compare(__LINE__, insert_into(bar).set(bar.textN = "cheesecake", bar.boolNn = true), "INSERT INTO tab_bar (text_n,bool_nn) VALUES('cheesecake'," + getTrue() + ")"); - compare(__LINE__, insert_into(bar).set(bar.textN = ::sqlpp::null, bar.boolNn = true), + compare(__LINE__, insert_into(bar).set(bar.textN = ::sqlpp::compat::nullopt, bar.boolNn = true), "INSERT INTO tab_bar (text_n,bool_nn) VALUES(NULL," + getTrue() + ")"); sqlpp::compat::string_view cheeseCake = "cheesecake"; compare(__LINE__, insert_into(bar).set(bar.textN = std::string(cheeseCake), bar.boolNn = true),