mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Added a few types/templates to help with expression tree evaluation
This commit is contained in:
parent
b907e3482d
commit
7afd34c349
@ -44,6 +44,7 @@ namespace sqlpp
|
||||
struct column_t: public ColumnSpec::_value_type::template operators<column_t<Table, ColumnSpec>>
|
||||
{
|
||||
using _is_column = std::true_type;
|
||||
using _spec_t = ColumnSpec;
|
||||
using _table = Table;
|
||||
using _column_type = typename ColumnSpec::_column_type;
|
||||
struct _value_type: ColumnSpec::_value_type
|
||||
|
@ -30,9 +30,11 @@
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/parameter_list.h>
|
||||
#include <sqlpp11/prepared_insert.h>
|
||||
#include <sqlpp11/default_value.h>
|
||||
#include <sqlpp11/vendor/column_list.h>
|
||||
#include <sqlpp11/vendor/noop.h>
|
||||
#include <sqlpp11/vendor/insert_list.h>
|
||||
#include <sqlpp11/vendor/assignment.h>
|
||||
#include <sqlpp11/vendor/insert_value_list.h>
|
||||
|
||||
namespace sqlpp
|
||||
|
10
include/sqlpp11/vendor/expression.h
vendored
10
include/sqlpp11/vendor/expression.h
vendored
@ -164,10 +164,12 @@ namespace sqlpp
|
||||
template<typename Lhs, typename O, typename Rhs>
|
||||
struct binary_expression_t: public O::_value_type::template operators<binary_expression_t<Lhs, O, Rhs>>
|
||||
{
|
||||
using _lhs_t = Lhs;
|
||||
using _rhs_t = Rhs;
|
||||
using _value_type = typename O::_value_type;
|
||||
using _parameter_tuple_t = std::tuple<Lhs, Rhs>;
|
||||
using _parameter_tuple_t = std::tuple<_lhs_t, _rhs_t>;
|
||||
|
||||
binary_expression_t(Lhs lhs, Rhs rhs):
|
||||
binary_expression_t(_lhs_t lhs, _rhs_t rhs):
|
||||
_lhs(lhs),
|
||||
_rhs(rhs)
|
||||
{}
|
||||
@ -178,8 +180,8 @@ namespace sqlpp
|
||||
binary_expression_t& operator=(binary_expression_t&&) = default;
|
||||
~binary_expression_t() = default;
|
||||
|
||||
Lhs _lhs;
|
||||
Rhs _rhs;
|
||||
_lhs_t _lhs;
|
||||
_rhs_t _rhs;
|
||||
};
|
||||
|
||||
template<typename Context, typename Lhs, typename O, typename Rhs>
|
||||
|
6
include/sqlpp11/vendor/insert_list.h
vendored
6
include/sqlpp11/vendor/insert_list.h
vendored
@ -61,6 +61,10 @@ namespace sqlpp
|
||||
using _is_insert_list = std::true_type;
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
using _parameter_tuple_t = std::tuple<Assignments...>;
|
||||
template<template<typename...> class Target>
|
||||
using copy_assignments_t = Target<Assignments...>; // FIXME: Nice idea to copy variadic template arguments?
|
||||
template<template<typename...> class Target, template<typename> class Wrap>
|
||||
using copy_wrapped_assignments_t = Target<Wrap<Assignments>...>;
|
||||
|
||||
// check for at least one order expression
|
||||
static_assert(_is_dynamic::value or sizeof...(Assignments), "at least one select expression required in set()");
|
||||
@ -75,6 +79,7 @@ namespace sqlpp
|
||||
static_assert(not sqlpp::detail::or_t<must_not_insert_t, typename Assignments::_column_t...>::value, "at least one assignment is prohibited by its column definition in set()");
|
||||
|
||||
insert_list_t(Assignments... assignment):
|
||||
_assignments(assignment...),
|
||||
_columns({assignment._lhs}...),
|
||||
_values(assignment._rhs...)
|
||||
{}
|
||||
@ -97,6 +102,7 @@ namespace sqlpp
|
||||
|
||||
std::tuple<simple_column_t<typename Assignments::_column_t>...> _columns;
|
||||
std::tuple<typename Assignments::value_type...> _values;
|
||||
std::tuple<Assignments...> _assignments; // FIXME: Need to replace _columns and _values by _assignments (connector-container requires assignments)
|
||||
typename vendor::interpretable_list_t<Database> _dynamic_columns;
|
||||
typename vendor::interpretable_list_t<Database> _dynamic_values;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user