mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 12:51:13 +08:00
Reactivate more tests
This commit is contained in:
parent
4e75cf349b
commit
d2cb720746
@ -86,16 +86,14 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename Table, typename ColumnSpec>
|
template<typename Table, typename ColumnSpec>
|
||||||
struct name_tag_of<column_t<Table, ColumnSpec>>
|
struct name_tag_of<column_t<Table, ColumnSpec>> : public name_tag_of<ColumnSpec>{};
|
||||||
{
|
|
||||||
using type = typename ColumnSpec::_alias_t;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Table, typename ColumnSpec>
|
template<typename Table, typename ColumnSpec>
|
||||||
struct has_default<column_t<Table, ColumnSpec>> : public ColumnSpec::has_default
|
struct has_default<column_t<Table, ColumnSpec>> : public ColumnSpec::has_default
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#warning: Do we need this?
|
||||||
template<typename Table, typename ColumnSpec>
|
template<typename Table, typename ColumnSpec>
|
||||||
struct has_name<column_t<Table, ColumnSpec>> : std::true_type
|
struct has_name<column_t<Table, ColumnSpec>> : std::true_type
|
||||||
{
|
{
|
||||||
|
@ -88,10 +88,11 @@ namespace sqlpp
|
|||||||
using type = cte_ref_t<AliasProvider>;
|
using type = cte_ref_t<AliasProvider>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#warning: Why can't we use FieldSpec directly? If not, does this one need to inherit from name_tag_base?
|
||||||
template <typename FieldSpec>
|
template <typename FieldSpec>
|
||||||
struct cte_column_spec_t
|
struct cte_column_spec_t
|
||||||
{
|
{
|
||||||
using _alias_t = typename FieldSpec::_alias_t;
|
using _alias_t = name_tag_of_t<FieldSpec>;
|
||||||
|
|
||||||
using _traits = make_traits<value_type_of_t<FieldSpec>>;
|
using _traits = make_traits<value_type_of_t<FieldSpec>>;
|
||||||
};
|
};
|
||||||
@ -155,7 +156,6 @@ namespace sqlpp
|
|||||||
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Statement>, detail::type_set<AliasProvider>>;
|
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Statement>, detail::type_set<AliasProvider>>;
|
||||||
using _parameters = parameters_of<Statement>;
|
using _parameters = parameters_of<Statement>;
|
||||||
|
|
||||||
using _alias_t = typename AliasProvider::_alias_t;
|
|
||||||
constexpr static bool _is_recursive = required_ctes_of<Statement>::template count<AliasProvider>();
|
constexpr static bool _is_recursive = required_ctes_of<Statement>::template count<AliasProvider>();
|
||||||
|
|
||||||
using _column_tuple_t = std::tuple<column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>...>;
|
using _column_tuple_t = std::tuple<column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>...>;
|
||||||
@ -240,8 +240,6 @@ namespace sqlpp
|
|||||||
using _required_ctes = detail::make_type_set_t<AliasProvider>;
|
using _required_ctes = detail::make_type_set_t<AliasProvider>;
|
||||||
using _provided_tables = detail::type_set<AliasProvider>;
|
using _provided_tables = detail::type_set<AliasProvider>;
|
||||||
|
|
||||||
using _alias_t = typename AliasProvider::_alias_t;
|
|
||||||
|
|
||||||
template <typename Statement>
|
template <typename Statement>
|
||||||
auto as(Statement statement) -> make_cte_t<AliasProvider, Statement>
|
auto as(Statement statement) -> make_cte_t<AliasProvider, Statement>
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
|
#warning: Do we need this? It should be possible to use name_tag_of_t and value_type_of_t somehow
|
||||||
template <typename NameType, typename ValueType>
|
template <typename NameType, typename ValueType>
|
||||||
struct field_spec_t
|
struct field_spec_t
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ namespace sqlpp
|
|||||||
-> decltype(_columns)
|
-> decltype(_columns)
|
||||||
{
|
{
|
||||||
(void)assignments;
|
(void)assignments;
|
||||||
return decltype(_columns)(std::get<Indexes>(assignments)._lhs...);
|
return decltype(_columns)(std::get<Indexes>(assignments)._l...);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto columns_from_tuple(std::tuple<Assignments...> assignments) -> decltype(_columns)
|
auto columns_from_tuple(std::tuple<Assignments...> assignments) -> decltype(_columns)
|
||||||
@ -125,7 +125,7 @@ namespace sqlpp
|
|||||||
-> decltype(_values)
|
-> decltype(_values)
|
||||||
{
|
{
|
||||||
(void)assignments;
|
(void)assignments;
|
||||||
return decltype(_values)(std::get<Indexes>(assignments)._rhs...);
|
return decltype(_values)(std::get<Indexes>(assignments)._r...);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto values_from_tuple(std::tuple<Assignments...> assignments) -> decltype(_values)
|
auto values_from_tuple(std::tuple<Assignments...> assignments) -> decltype(_values)
|
||||||
|
@ -38,8 +38,7 @@ namespace sqlpp
|
|||||||
template <typename Expr>
|
template <typename Expr>
|
||||||
struct check_on
|
struct check_on
|
||||||
{
|
{
|
||||||
using type = static_combined_check_t<static_check_t<is_expression_t<Expr>::value, assert_on_is_expression_t>,
|
using type = static_combined_check_t<static_check_t<is_boolean<Expr>::value, assert_on_is_boolean_expression_t>>;
|
||||||
static_check_t<is_boolean<Expr>::value, assert_on_is_boolean_expression_t>>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Expr>
|
template <typename Expr>
|
||||||
|
@ -51,9 +51,6 @@ namespace sqlpp
|
|||||||
struct returning_traits
|
struct returning_traits
|
||||||
{
|
{
|
||||||
using _traits = make_traits<no_value_t, tag::is_returning_column_list, tag::is_return_value>;
|
using _traits = make_traits<no_value_t, tag::is_returning_column_list, tag::is_return_value>;
|
||||||
struct _alias_t
|
|
||||||
{
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Column>
|
template <typename Column>
|
||||||
@ -64,7 +61,6 @@ namespace sqlpp
|
|||||||
tag::is_return_value,
|
tag::is_return_value,
|
||||||
tag::is_expression,
|
tag::is_expression,
|
||||||
tag::is_selectable>; // TODO: Is this correct?
|
tag::is_selectable>; // TODO: Is this correct?
|
||||||
using _alias_t = typename Column::_alias_t;
|
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@ -96,7 +92,6 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
using _traits = typename detail::returning_traits<Columns...>::_traits;
|
using _traits = typename detail::returning_traits<Columns...>::_traits;
|
||||||
using _nodes = ::sqlpp::detail::type_vector<Columns...>;
|
using _nodes = ::sqlpp::detail::type_vector<Columns...>;
|
||||||
using _alias_t = typename detail::returning_traits<Columns...>::_alias_t;
|
|
||||||
|
|
||||||
struct _column_type
|
struct _column_type
|
||||||
{
|
{
|
||||||
@ -157,6 +152,7 @@ namespace sqlpp
|
|||||||
template <typename AliasProvider>
|
template <typename AliasProvider>
|
||||||
using _table_t = typename _deferred_table_t<AliasProvider>::table;
|
using _table_t = typename _deferred_table_t<AliasProvider>::table;
|
||||||
|
|
||||||
|
#warning: review all the alias stuff here
|
||||||
template <typename AliasProvider>
|
template <typename AliasProvider>
|
||||||
using _alias_t = typename _deferred_table_t<AliasProvider>::alias;
|
using _alias_t = typename _deferred_table_t<AliasProvider>::alias;
|
||||||
|
|
||||||
@ -203,6 +199,16 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Column>
|
||||||
|
struct value_type_of<returning_column_list_t<Columns...>> : public value_type_of<Column>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Column>
|
||||||
|
struct name_tag_of<returning_column_list_t<Columns...>> : public name_tag_of<Column>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template <typename... Columns>
|
template <typename... Columns>
|
||||||
|
@ -35,9 +35,10 @@ namespace sqlpp
|
|||||||
//
|
//
|
||||||
// provide type information for sub-selects that are used as named expressions or tables
|
// provide type information for sub-selects that are used as named expressions or tables
|
||||||
template <typename Select, typename NamedExpr>
|
template <typename Select, typename NamedExpr>
|
||||||
struct select_column_spec_t
|
struct select_column_spec_t: public name_tag_base
|
||||||
{
|
{
|
||||||
using _alias_t = name_tag_of_t<NamedExpr>;
|
using _alias_t = name_tag_of_t<NamedExpr>;
|
||||||
|
using has_default = std::false_type;
|
||||||
|
|
||||||
static constexpr bool _depends_on_outer_table =
|
static constexpr bool _depends_on_outer_table =
|
||||||
detail::make_intersect_set_t<required_tables_of_t<NamedExpr>, typename Select::_used_outer_tables>::size::value >
|
detail::make_intersect_set_t<required_tables_of_t<NamedExpr>, typename Select::_used_outer_tables>::size::value >
|
||||||
|
@ -47,6 +47,9 @@ namespace sqlpp
|
|||||||
using _provided_tables = detail::type_set<Table>;
|
using _provided_tables = detail::type_set<Table>;
|
||||||
|
|
||||||
static_assert(sizeof...(ColumnSpec) > 0, "at least one column required per table");
|
static_assert(sizeof...(ColumnSpec) > 0, "at least one column required per table");
|
||||||
|
template<typename T> struct require_insert : std::integral_constant<bool, not has_default<T>::value>{};
|
||||||
|
using _required_insert_columns =
|
||||||
|
typename detail::make_type_set_if<require_insert, column_t<Table, ColumnSpec>...>::type;
|
||||||
using _column_tuple_t = std::tuple<column_t<Table, ColumnSpec>...>;
|
using _column_tuple_t = std::tuple<column_t<Table, ColumnSpec>...>;
|
||||||
template <typename AliasProvider, typename T>
|
template <typename AliasProvider, typename T>
|
||||||
using _foreign_table_alias_t = table_alias_t<AliasProvider, T, ColumnSpec...>;
|
using _foreign_table_alias_t = table_alias_t<AliasProvider, T, ColumnSpec...>;
|
||||||
@ -102,7 +105,7 @@ namespace sqlpp
|
|||||||
template <typename Context, typename Table, typename... ColumnSpec>
|
template <typename Context, typename Table, typename... ColumnSpec>
|
||||||
Context& serialize(Context& context, const table_t<Table, ColumnSpec...>& /*unused*/)
|
Context& serialize(Context& context, const table_t<Table, ColumnSpec...>& /*unused*/)
|
||||||
{
|
{
|
||||||
context << Table::_alias_t::_name_t::template char_ptr<Context>();
|
context << name_tag_of_t<Table>::_name_t::template char_ptr<Context>();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
@ -64,10 +64,6 @@ namespace sqlpp
|
|||||||
using _traits = make_traits<no_value_t, tag::is_union, tag::is_return_value>;
|
using _traits = make_traits<no_value_t, tag::is_union, tag::is_return_value>;
|
||||||
using _nodes = detail::type_vector<Lhs, Rhs>;
|
using _nodes = detail::type_vector<Lhs, Rhs>;
|
||||||
|
|
||||||
using _alias_t = struct
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
using _data_t = union_data_t<Flag, Lhs, Rhs>;
|
using _data_t = union_data_t<Flag, Lhs, Rhs>;
|
||||||
|
|
||||||
// Base template to be inherited by the statement
|
// Base template to be inherited by the statement
|
||||||
|
@ -55,6 +55,12 @@ namespace sqlpp
|
|||||||
std::string _verbatim;
|
std::string _verbatim;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename ValueType>
|
||||||
|
struct value_type_of<verbatim_t<ValueType>>
|
||||||
|
{
|
||||||
|
using type = ValueType;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Context, typename ValueType>
|
template <typename Context, typename ValueType>
|
||||||
Context& serialize(Context& context, const verbatim_t<ValueType>& t)
|
Context& serialize(Context& context, const verbatim_t<ValueType>& t)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
using _traits = make_traits<no_value_t>;
|
using _traits = make_traits<no_value_t>;
|
||||||
|
using has_default = std::false_type;
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ set(test_files
|
|||||||
Exists.cpp
|
Exists.cpp
|
||||||
Float.cpp
|
Float.cpp
|
||||||
#ForUpdate.cpp
|
#ForUpdate.cpp
|
||||||
#From.cpp
|
From.cpp
|
||||||
In.cpp
|
In.cpp
|
||||||
#Insert.cpp
|
Insert.cpp
|
||||||
IsNotNull.cpp
|
IsNotNull.cpp
|
||||||
IsNull.cpp
|
IsNull.cpp
|
||||||
Lower.cpp
|
Lower.cpp
|
||||||
@ -48,7 +48,7 @@ set(test_files
|
|||||||
SelectColumns.cpp
|
SelectColumns.cpp
|
||||||
SelectFlags.cpp
|
SelectFlags.cpp
|
||||||
Sum.cpp
|
Sum.cpp
|
||||||
#TableAlias.cpp
|
TableAlias.cpp
|
||||||
Trim.cpp
|
Trim.cpp
|
||||||
Upper.cpp
|
Upper.cpp
|
||||||
Where.cpp
|
Where.cpp
|
||||||
|
@ -34,7 +34,7 @@ namespace
|
|||||||
auto getTrue() -> std::string
|
auto getTrue() -> std::string
|
||||||
{
|
{
|
||||||
MockDb::_serializer_context_t printer = {};
|
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).default_values(), "INSERT INTO tab_bar DEFAULT VALUES");
|
||||||
compare(__LINE__, insert_into(bar).set(bar.textN = "cheesecake", bar.boolNn = true),
|
compare(__LINE__, insert_into(bar).set(bar.textN = "cheesecake", bar.boolNn = true),
|
||||||
"INSERT INTO tab_bar (text_n,bool_nn) VALUES('cheesecake'," + getTrue() + ")");
|
"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() + ")");
|
"INSERT INTO tab_bar (text_n,bool_nn) VALUES(NULL," + getTrue() + ")");
|
||||||
sqlpp::compat::string_view cheeseCake = "cheesecake";
|
sqlpp::compat::string_view cheeseCake = "cheesecake";
|
||||||
compare(__LINE__, insert_into(bar).set(bar.textN = std::string(cheeseCake), bar.boolNn = true),
|
compare(__LINE__, insert_into(bar).set(bar.textN = std::string(cheeseCake), bar.boolNn = true),
|
||||||
|
Loading…
Reference in New Issue
Block a user