mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 12:29:41 +08:00
Reformatted using clang-format
Please use clang-format before submitting code, e.g via the pre-commit supplied in the repo (thanks AndiDog)
This commit is contained in:
parent
46c565c5c5
commit
09f23cea0a
@ -14,7 +14,7 @@ BreakBeforeBinaryOperators: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BinPackParameters: false
|
||||
ColumnLimit: 160
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
DerivePointerAlignment: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
|
@ -24,7 +24,6 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SQLPP_DATABASE_BIND_RESULT_H
|
||||
#define SQLPP_DATABASE_BIND_RESULT_H
|
||||
|
||||
@ -87,7 +86,6 @@ namespace sqlpp
|
||||
void _bind_text_result(size_t index, const char** text, size_t* len);
|
||||
...
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -24,7 +24,6 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SQLPP_DATABASE_CONNECTION_H
|
||||
#define SQLPP_DATABASE_CONNECTION_H
|
||||
|
||||
@ -51,13 +50,15 @@ namespace sqlpp
|
||||
class connection : public sqlpp::connection // this inheritance helps with ADL for dynamic_select, for instance
|
||||
{
|
||||
public:
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::no_value_t,
|
||||
using _traits = ::sqlpp::make_traits<
|
||||
::sqlpp::no_value_t,
|
||||
::sqlpp::tag::enforce_null_result_treatment // If that is what you really want, leave it out otherwise
|
||||
>;
|
||||
|
||||
using _prepared_statement_t = << handle to a prepared statement of the database >> ;
|
||||
using _serializer_context_t = << This context is used to serialize a statement >>
|
||||
using _interpreter_context_t = << This context is used interpret a statement >>;
|
||||
using _serializer_context_t = << This context is used to serialize a statement >> using _interpreter_context_t =
|
||||
<< This context is used interpret a statement >>
|
||||
;
|
||||
// serializer and interpreter are typically the same for string based connectors
|
||||
// the types are required for dynamic statement components, see sqlpp11/interpretable.h
|
||||
|
||||
@ -70,14 +71,16 @@ namespace sqlpp
|
||||
|
||||
//! "direct" select
|
||||
template <typename Select>
|
||||
<<bind_result_t>> select(const Select& s);
|
||||
<< bind_result_t >>
|
||||
select(const Select& s);
|
||||
|
||||
//! prepared select
|
||||
template <typename Select>
|
||||
_prepared_statement_t prepare_select(Select& s);
|
||||
|
||||
template <typename PreparedSelect>
|
||||
<<bind_result_t>> run_prepared_select(const PreparedSelect& s); // call s._bind_params()
|
||||
<< bind_result_t >>
|
||||
run_prepared_select(const PreparedSelect& s); // call s._bind_params()
|
||||
|
||||
//! "direct insert
|
||||
template <typename Insert>
|
||||
@ -132,13 +135,13 @@ namespace sqlpp
|
||||
//! commit transaction (or throw transaction if the transaction has been finished already)
|
||||
void commit_transaction();
|
||||
|
||||
//! rollback transaction with or without reporting the rollback (or throw if the transaction has been finished already)
|
||||
//! rollback transaction with or without reporting the rollback (or throw if the transaction has been finished
|
||||
// already)
|
||||
void rollback_transaction(bool report);
|
||||
|
||||
//! report a rollback failure (will be called by transactions in case of a rollback failure in the destructor)
|
||||
void report_rollback_failure(const std::string message) noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SQLPP_DATABASE_PREPARED_STATEMENT_H
|
||||
#define SQLPP_DATABASE_PREPARED_STATEMENT_H
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <sqlpp11/column_types.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
// clang-format off
|
||||
namespace test
|
||||
{
|
||||
namespace TabPerson_
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <sqlpp11/table_base.h>
|
||||
#include <sqlpp11/column_types.h>
|
||||
|
||||
|
||||
// clang-format off
|
||||
namespace TabFoo_
|
||||
{
|
||||
struct Omega
|
||||
|
@ -50,7 +50,6 @@ int insert(int, char**)
|
||||
|
||||
// db(insert_into(f).set(f.name = "loves c++"));
|
||||
|
||||
|
||||
db(insert_into(f).default_values());
|
||||
|
||||
auto i = insert_into(p).columns(p.name, p.feature);
|
||||
@ -58,7 +57,6 @@ int insert(int, char**)
|
||||
i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value);
|
||||
db(i);
|
||||
|
||||
|
||||
auto pi = db.prepare(insert_into(p).set(p.name = parameter(f.name), p.feature = parameter(p.feature)));
|
||||
pi.params.name = "likes java";
|
||||
pi.params.feature = true;
|
||||
|
@ -45,6 +45,7 @@ SQLPP_DECLARE_TABLE(
|
||||
|
||||
#include "MockDb.h"
|
||||
|
||||
// clang-format off
|
||||
SQLPP_DECLARE_TABLE(
|
||||
(tab_person)
|
||||
,
|
||||
@ -60,6 +61,7 @@ SQLPP_DECLARE_TABLE(
|
||||
(name , varchar(255), SQLPP_NULL )
|
||||
(fatal, bool , SQLPP_NOT_NULL )
|
||||
)
|
||||
// clang-format on
|
||||
|
||||
int ppgen(int, char**)
|
||||
{
|
||||
@ -83,7 +85,6 @@ int ppgen(int, char**)
|
||||
|
||||
// db(insert_into(f).set(f.name = "loves c++"));
|
||||
|
||||
|
||||
db(insert_into(f).default_values());
|
||||
|
||||
auto i = insert_into(p).columns(p.name, p.feature);
|
||||
@ -91,7 +92,6 @@ int ppgen(int, char**)
|
||||
i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value);
|
||||
db(i);
|
||||
|
||||
|
||||
auto pi = db.prepare(insert_into(p).set(p.name = parameter(f.name), p.feature = parameter(p.feature)));
|
||||
pi.params.name = "likes java";
|
||||
pi.params.feature = true;
|
||||
|
@ -34,8 +34,6 @@ int remove(int, char**)
|
||||
test::TabPerson p;
|
||||
test::TabFeature q;
|
||||
|
||||
db(remove_from(p)
|
||||
.using_(p, q)
|
||||
.where(p.feature == q.id and q.fatal == true));
|
||||
db(remove_from(p).using_(p, q).where(p.feature == q.id and q.fatal == true));
|
||||
return 0;
|
||||
}
|
||||
|
@ -40,18 +40,15 @@ int main()
|
||||
|
||||
auto s = select(all_of(p))
|
||||
.from(p, q)
|
||||
.where(p.name == any(select(q.name)
|
||||
.from(q)
|
||||
.where(true)))
|
||||
.where(p.name == any(select(q.name).from(q).where(true)))
|
||||
.group_by(q.name)
|
||||
.having(p.name.like("%Bee%"))
|
||||
.order_by(p.name.asc())
|
||||
.limit(3).offset(7);
|
||||
.limit(3)
|
||||
.offset(7);
|
||||
|
||||
auto x = s.as(sqlpp::alias::x);
|
||||
for (const auto& row : db(select(p.id, x.name)
|
||||
.from(p.join(x).on(p.feature == x.feature))
|
||||
.where(true)))
|
||||
for (const auto& row : db(select(p.id, x.name).from(p.join(x).on(p.feature == x.feature)).where(true)))
|
||||
{
|
||||
int id = row.id;
|
||||
std::string name = row.name;
|
||||
|
@ -53,7 +53,6 @@ int select(int, char**)
|
||||
int64_t feature = row.feature;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
for (const auto& row : db(select(p.name).from(p).where(p.name.like("Herb%"))))
|
||||
{
|
||||
@ -63,8 +62,6 @@ int select(int, char**)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
for (const auto& row : db(select(p.name, f.name.as(cheesecake)).from(p,f).where(p.id > 7 and p.feature == 3)))
|
||||
{
|
||||
@ -75,8 +72,6 @@ int select(int, char**)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
for (const auto& row : db(select(multi_column(all_of(p)).as(p), multi_column(f.name, f.id).as(f)).from(p,f).where(true)))
|
||||
{
|
||||
@ -88,12 +83,6 @@ int select(int, char**)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
auto s = select(p.id, p.name, f.id.as(cheesecake))
|
||||
.from(p, f)
|
||||
@ -117,8 +106,6 @@ int select(int, char**)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if !0
|
||||
auto dysel = dynamic_select(db).dynamic_columns(p.name).from(p).dynamic_where();
|
||||
|
||||
@ -135,23 +122,5 @@ int select(int, char**)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ namespace sqlpp
|
||||
|
||||
using _alias_t = typename AliasProvider::_alias_t;
|
||||
|
||||
expression_alias_t(Expression expression):
|
||||
_expression(expression)
|
||||
{}
|
||||
expression_alias_t(Expression expression) : _expression(expression)
|
||||
{
|
||||
}
|
||||
|
||||
expression_alias_t(const expression_alias_t&) = default;
|
||||
expression_alias_t(expression_alias_t&&) = default;
|
||||
@ -70,7 +70,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,8 +41,14 @@
|
||||
struct _member_t \
|
||||
{ \
|
||||
T name; \
|
||||
T& operator()() { return name; }\
|
||||
const T& operator()() const { return name; }\
|
||||
T& operator()() \
|
||||
{ \
|
||||
return name; \
|
||||
} \
|
||||
const T& operator()() const \
|
||||
{ \
|
||||
return name; \
|
||||
} \
|
||||
}; \
|
||||
}; \
|
||||
}; \
|
||||
@ -57,7 +63,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_alias_provider_t<T, typename std::enable_if<std::is_class<typename T::_alias_t::template _member_t<int>>::value, void>::type>
|
||||
struct is_alias_provider_t<
|
||||
T,
|
||||
typename std::enable_if<std::is_class<typename T::_alias_t::template _member_t<int>>::value, void>::type>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
@ -95,4 +103,3 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -73,8 +73,6 @@ namespace sqlpp
|
||||
_serialize_check::_();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -39,9 +39,9 @@ namespace sqlpp
|
||||
using _traits = make_traits<value_type_of<Select>, tag::is_multi_expression>;
|
||||
using _nodes = detail::type_vector<Select>;
|
||||
|
||||
any_t(Select select):
|
||||
_select(select)
|
||||
{}
|
||||
any_t(Select select) : _select(select)
|
||||
{
|
||||
}
|
||||
|
||||
any_t(const any_t&) = default;
|
||||
any_t(any_t&&) = default;
|
||||
@ -71,11 +71,11 @@ namespace sqlpp
|
||||
auto any(T t) -> any_t<wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(is_select_t<wrap_operand_t<T>>::value, "any() requires a select expression as argument");
|
||||
static_assert(is_expression_t<wrap_operand_t<T>>::value, "any() requires a single column select expression as argument");
|
||||
static_assert(is_expression_t<wrap_operand_t<T>>::value,
|
||||
"any() requires a single column select expression as argument");
|
||||
// FIXME: can we accept non-values like NULL here?
|
||||
return {t};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -45,12 +45,13 @@ namespace sqlpp
|
||||
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
|
||||
using _nodes = detail::type_vector<_lhs_t, _rhs_t>;
|
||||
|
||||
static_assert(can_be_null_t<_lhs_t>::value ? true : not (std::is_same<_rhs_t, null_t>::value or is_tvin_t<_rhs_t>::value), "column must not be null");
|
||||
static_assert(can_be_null_t<_lhs_t>::value ? true
|
||||
: not(std::is_same<_rhs_t, null_t>::value or is_tvin_t<_rhs_t>::value),
|
||||
"column must not be null");
|
||||
|
||||
assignment_t(_lhs_t lhs, _rhs_t rhs):
|
||||
_lhs(lhs),
|
||||
_rhs(rhs)
|
||||
{}
|
||||
assignment_t(_lhs_t lhs, _rhs_t rhs) : _lhs(lhs), _rhs(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
assignment_t(const assignment_t&) = default;
|
||||
assignment_t(assignment_t&&) = default;
|
||||
@ -76,7 +77,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -62,5 +62,4 @@ namespace sqlpp
|
||||
using auto_alias_t = typename detail::auto_alias_impl<T>::type;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -42,28 +42,34 @@ namespace sqlpp
|
||||
struct _member_t
|
||||
{
|
||||
T avg;
|
||||
T& operator()() { return avg; }
|
||||
const T& operator()() const { return avg; }
|
||||
T& operator()()
|
||||
{
|
||||
return avg;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return avg;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
struct avg_t:
|
||||
public expression_operators<avg_t<Flag, Expr>, floating_point>,
|
||||
struct avg_t : public expression_operators<avg_t<Flag, Expr>, floating_point>,
|
||||
public alias_operators<avg_t<Flag, Expr>>
|
||||
{
|
||||
using _traits = make_traits<floating_point, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
|
||||
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value, "avg() used with flag other than 'distinct'");
|
||||
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value,
|
||||
"avg() used with flag other than 'distinct'");
|
||||
static_assert(is_numeric_t<Expr>::value, "avg() requires a value expression as argument");
|
||||
|
||||
using _auto_alias_t = avg_alias_t;
|
||||
|
||||
avg_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
avg_t(Expr expr) : _expr(expr)
|
||||
{
|
||||
}
|
||||
|
||||
avg_t(const avg_t&) = default;
|
||||
avg_t(avg_t&&) = default;
|
||||
@ -101,7 +107,8 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
auto avg(T t) -> avg_t<noop, wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "avg() cannot be used on an aggregate function");
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
|
||||
"avg() cannot be used on an aggregate function");
|
||||
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "avg() requires a value expression as argument");
|
||||
return {t};
|
||||
}
|
||||
@ -109,11 +116,11 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
auto avg(const distinct_t&, T t) -> avg_t<distinct_t, wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "avg() cannot be used on an aggregate function");
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
|
||||
"avg() cannot be used on an aggregate function");
|
||||
static_assert(is_numeric_t<wrap_operand_t<T>>::value, "avg() requires a value expression as argument");
|
||||
return {t};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -32,10 +32,10 @@ namespace sqlpp
|
||||
struct bad_statement
|
||||
{
|
||||
template <typename... T>
|
||||
bad_statement(T&&...) {}
|
||||
bad_statement(T&&...)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -47,8 +47,10 @@ namespace sqlpp
|
||||
{
|
||||
static constexpr bool value =
|
||||
(is_expression_t<T>::value // expressions are OK
|
||||
or is_multi_expression_t<T>::value) // multi-expressions like ANY are OK for comparisons, too
|
||||
and ValueType::template _is_valid_operand<T>::value // the correct value type is required, of course
|
||||
or
|
||||
is_multi_expression_t<T>::value) // multi-expressions like ANY are OK for comparisons, too
|
||||
and
|
||||
ValueType::template _is_valid_operand<T>::value // the correct value type is required, of course
|
||||
;
|
||||
};
|
||||
|
||||
@ -130,14 +132,16 @@ namespace sqlpp
|
||||
template <typename... T>
|
||||
in_t<Expr, wrap_operand_t<T>...> in(T... t) const
|
||||
{
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value, "at least one operand of in() is not valid");
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value,
|
||||
"at least one operand of in() is not valid");
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
not_in_t<Expr, wrap_operand_t<T>...> not_in(T... t) const
|
||||
{
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value, "at least one operand of in() is not valid");
|
||||
static_assert(logic::all_t<_is_valid_comparison_operand<wrap_operand_t<T>>::value...>::value,
|
||||
"at least one operand of in() is not valid");
|
||||
return {*static_cast<const Expr*>(this), wrap_operand_t<T>{t}...};
|
||||
}
|
||||
};
|
||||
@ -151,6 +155,5 @@ namespace sqlpp
|
||||
return {*static_cast<const Expr*>(this)};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -55,15 +55,13 @@ namespace sqlpp
|
||||
using _value_type = boolean; // FIXME
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t():
|
||||
_value(false),
|
||||
_is_null(true)
|
||||
{}
|
||||
parameter_value_t() : _value(false), _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t(const _cpp_value_type& val):
|
||||
_value(val),
|
||||
_is_null(false)
|
||||
{}
|
||||
parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
@ -104,7 +102,10 @@ namespace sqlpp
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const { return value(); }
|
||||
operator _cpp_value_type() const
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
@ -161,11 +162,9 @@ namespace sqlpp
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, boolean>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename boolean::_cpp_value_type;
|
||||
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
_is_null(true),
|
||||
_value(false)
|
||||
{}
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value(false)
|
||||
{
|
||||
}
|
||||
|
||||
void _validate()
|
||||
{
|
||||
@ -230,6 +229,5 @@ namespace sqlpp
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -39,8 +39,8 @@ namespace sqlpp
|
||||
using _nodes = detail::type_vector<>;
|
||||
|
||||
template <typename Expr>
|
||||
boolean_expression_t(Expr expr):
|
||||
_expr(expr)
|
||||
boolean_expression_t(Expr expr)
|
||||
: _expr(expr)
|
||||
{
|
||||
static_assert(is_expression_t<Expr>::value, "boolean_expression requires a boolean expression argument");
|
||||
static_assert(is_boolean_t<Expr>::value, "boolean_expression requires a boolean expression argument");
|
||||
@ -79,7 +79,6 @@ namespace sqlpp
|
||||
return serialize(t._expr, context);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -31,7 +31,8 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template<char... Cs> struct char_sequence
|
||||
template <char... Cs>
|
||||
struct char_sequence
|
||||
{
|
||||
static const char* char_ptr()
|
||||
{
|
||||
@ -50,7 +51,8 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <std::size_t N, const char(&Input)[N]>
|
||||
using make_char_sequence = typename make_char_sequence_impl<sizeof(Input), Input, sqlpp::detail::make_index_sequence<sizeof(Input)>>::type;
|
||||
using make_char_sequence =
|
||||
typename make_char_sequence_impl<sizeof(Input), Input, sqlpp::detail::make_index_sequence<sizeof(Input)>>::type;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -42,14 +42,14 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Table, typename ColumnSpec>
|
||||
struct column_t:
|
||||
public expression_operators<column_t<Table, ColumnSpec>, value_type_of<ColumnSpec>>,
|
||||
struct column_t : public expression_operators<column_t<Table, ColumnSpec>, value_type_of<ColumnSpec>>,
|
||||
public column_operators<column_t<Table, ColumnSpec>, value_type_of<ColumnSpec>>
|
||||
{
|
||||
struct _traits
|
||||
{
|
||||
using _value_type = value_type_of<ColumnSpec>;
|
||||
using _tags = detail::make_joined_set_t<detail::type_set<tag::is_column, tag::is_expression, tag::is_selectable>, typename ColumnSpec::_traits::_tags>;
|
||||
using _tags = detail::make_joined_set_t<detail::type_set<tag::is_column, tag::is_expression, tag::is_selectable>,
|
||||
typename ColumnSpec::_traits::_tags>;
|
||||
};
|
||||
|
||||
using _nodes = detail::type_vector<>;
|
||||
@ -92,15 +92,13 @@ namespace sqlpp
|
||||
return {*this, {rhs{t}}};
|
||||
}
|
||||
|
||||
auto operator =(null_t) const
|
||||
->assignment_t<column_t, null_t>
|
||||
auto operator=(null_t) const -> assignment_t<column_t, null_t>
|
||||
{
|
||||
static_assert(can_be_null_t<column_t>::value, "column cannot be null");
|
||||
return {*this, null_t{}};
|
||||
}
|
||||
|
||||
auto operator =(default_value_t) const
|
||||
->assignment_t<column_t, default_value_t>
|
||||
auto operator=(default_value_t) const -> assignment_t<column_t, default_value_t>
|
||||
{
|
||||
return {*this, default_value_t{}};
|
||||
}
|
||||
@ -118,7 +116,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -24,7 +24,6 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SQLPP_COLUMN_FWD_H
|
||||
#define SQLPP_COLUMN_FWD_H
|
||||
|
||||
|
@ -52,18 +52,16 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
struct concat_t:
|
||||
public expression_operators<concat_t<Args...>, text>,
|
||||
public alias_operators<concat_t<Args...>>
|
||||
struct concat_t : public expression_operators<concat_t<Args...>, text>, public alias_operators<concat_t<Args...>>
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Args...>;
|
||||
|
||||
using _auto_alias_t = concat_alias_t;
|
||||
|
||||
concat_t(Args... args):
|
||||
_args(args...)
|
||||
{}
|
||||
concat_t(Args... args) : _args(args...)
|
||||
{
|
||||
}
|
||||
|
||||
concat_t(const concat_t&) = default;
|
||||
concat_t(concat_t&&) = default;
|
||||
@ -90,11 +88,11 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
auto concat(Args... args)
|
||||
-> concat_t<Args...>
|
||||
auto concat(Args... args) -> concat_t<Args...>
|
||||
{
|
||||
static_assert(sizeof...(Args) >= 2, "concat requires two arguments at least");
|
||||
static_assert(logic::all_t<is_text_t<wrap_operand_t<Args>>::value...>::value, "at least one non-text argument detected in concat()");
|
||||
static_assert(logic::all_t<is_text_t<wrap_operand_t<Args>>::value...>::value,
|
||||
"at least one non-text argument detected in concat()");
|
||||
|
||||
return {args...};
|
||||
}
|
||||
|
@ -29,8 +29,9 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct connection {};
|
||||
struct connection
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -43,15 +43,20 @@ namespace sqlpp
|
||||
struct _member_t
|
||||
{
|
||||
T count;
|
||||
T& operator()() { return count; }
|
||||
const T& operator()() const { return count; }
|
||||
T& operator()()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return count;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
struct count_t:
|
||||
public expression_operators<count_t<Flag, Expr>, integral>,
|
||||
struct count_t : public expression_operators<count_t<Flag, Expr>, integral>,
|
||||
public alias_operators<count_t<Flag, Expr>>
|
||||
{
|
||||
using _traits = make_traits<integral, tag::is_expression /*, tag::is_selectable*/>;
|
||||
@ -59,13 +64,14 @@ namespace sqlpp
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
using _can_be_null = std::false_type;
|
||||
|
||||
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value, "count() used with flag other than 'distinct'");
|
||||
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value,
|
||||
"count() used with flag other than 'distinct'");
|
||||
|
||||
using _auto_alias_t = count_alias_t;
|
||||
|
||||
count_t(const Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
count_t(const Expr expr) : _expr(expr)
|
||||
{
|
||||
}
|
||||
|
||||
count_t(const count_t&) = default;
|
||||
count_t(count_t&&) = default;
|
||||
@ -103,7 +109,8 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
auto count(T t) -> count_t<noop, wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "count() cannot be used on an aggregate function");
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
|
||||
"count() cannot be used on an aggregate function");
|
||||
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
|
||||
return {t};
|
||||
}
|
||||
@ -111,11 +118,11 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
auto count(const distinct_t&, T t) -> count_t<distinct_t, wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "count() cannot be used on an aggregate function");
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
|
||||
"count() cannot be used on an aggregate function");
|
||||
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
|
||||
return {t};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -47,10 +47,9 @@ namespace sqlpp
|
||||
using _required_ctes = detail::make_joined_set_t<required_ctes_of<Lhs>, required_ctes_of<Rhs>>;
|
||||
using _parameters = detail::type_vector_cat_t<parameters_of<Lhs>, parameters_of<Rhs>>;
|
||||
|
||||
cte_union_t(Lhs lhs, Rhs rhs):
|
||||
_lhs(lhs),
|
||||
_rhs(rhs)
|
||||
{}
|
||||
cte_union_t(Lhs lhs, Rhs rhs) : _lhs(lhs), _rhs(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
cte_union_t(const cte_union_t&) = default;
|
||||
cte_union_t(cte_union_t&&) = default;
|
||||
@ -98,7 +97,6 @@ namespace sqlpp
|
||||
using type = cte_ref_t<AliasProvider>;
|
||||
};
|
||||
|
||||
|
||||
template <typename FieldSpec>
|
||||
struct cte_column_spec_t
|
||||
{
|
||||
@ -107,8 +105,7 @@ namespace sqlpp
|
||||
using _traits = make_traits<value_type_of<FieldSpec>,
|
||||
tag::must_not_insert,
|
||||
tag::must_not_update,
|
||||
tag_if<tag::can_be_null, column_spec_can_be_null_t<FieldSpec>::value>
|
||||
>;
|
||||
tag_if<tag::can_be_null, column_spec_can_be_null_t<FieldSpec>::value>>;
|
||||
};
|
||||
|
||||
template <typename AliasProvider, typename Statement, typename ResultRow>
|
||||
@ -127,7 +124,8 @@ namespace sqlpp
|
||||
using make_cte_t = typename make_cte_impl<AliasProvider, Statement, get_result_row_t<Statement>>::type;
|
||||
|
||||
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
|
||||
struct cte_t: public member_t<cte_column_spec_t<FieldSpecs>, column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>>...
|
||||
struct cte_t
|
||||
: public member_t<cte_column_spec_t<FieldSpecs>, column_t<AliasProvider, cte_column_spec_t<FieldSpecs>>>...
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::is_cte, tag::is_table>; // FIXME: is table? really?
|
||||
using _nodes = detail::type_vector<>;
|
||||
@ -145,35 +143,40 @@ namespace sqlpp
|
||||
using _result_row_t = result_row_t<void, FieldSpecs...>;
|
||||
|
||||
template <typename Rhs>
|
||||
auto union_distinct(Rhs rhs) const
|
||||
-> typename std::conditional<_check<Rhs>::value, cte_t<AliasProvider, cte_union_t<distinct_t, Statement, Rhs>, FieldSpecs...>, bad_statement>::type
|
||||
auto union_distinct(Rhs rhs) const ->
|
||||
typename std::conditional<_check<Rhs>::value,
|
||||
cte_t<AliasProvider, cte_union_t<distinct_t, Statement, Rhs>, FieldSpecs...>,
|
||||
bad_statement>::type
|
||||
{
|
||||
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
|
||||
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
|
||||
static_assert(has_result_row_t<Rhs>::value, "argument of a union has to be a (complete) select statement");
|
||||
|
||||
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value, "both select statements in a union have to have the same result columns (type and name)");
|
||||
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value,
|
||||
"both select statements in a union have to have the same result columns (type and name)");
|
||||
|
||||
return _union_impl<void, distinct_t>(_check<Rhs>{}, rhs);
|
||||
}
|
||||
|
||||
template <typename Rhs>
|
||||
auto union_all(Rhs rhs) const
|
||||
-> typename std::conditional<_check<Rhs>::value, cte_t<AliasProvider, cte_union_t<all_t, Statement, Rhs>, FieldSpecs...>, bad_statement>::type
|
||||
auto union_all(Rhs rhs) const ->
|
||||
typename std::conditional<_check<Rhs>::value,
|
||||
cte_t<AliasProvider, cte_union_t<all_t, Statement, Rhs>, FieldSpecs...>,
|
||||
bad_statement>::type
|
||||
{
|
||||
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
|
||||
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
|
||||
static_assert(has_result_row_t<Rhs>::value, "argument of a union has to be a (complete) select statement");
|
||||
|
||||
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value, "both select statements in a union have to have the same result columns (type and name)");
|
||||
static_assert(std::is_same<_result_row_t, get_result_row_t<Rhs>>::value,
|
||||
"both select statements in a union have to have the same result columns (type and name)");
|
||||
|
||||
return _union_impl<all_t>(_check<Rhs>{}, rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Flag, typename Rhs>
|
||||
auto _union_impl(const std::false_type&, Rhs rhs) const
|
||||
-> bad_statement;
|
||||
auto _union_impl(const std::false_type&, Rhs rhs) const -> bad_statement;
|
||||
|
||||
template <typename Flag, typename Rhs>
|
||||
auto _union_impl(const std::true_type&, Rhs rhs) const
|
||||
@ -183,8 +186,9 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
cte_t(Statement statement): _statement(statement){}
|
||||
cte_t(Statement statement) : _statement(statement)
|
||||
{
|
||||
}
|
||||
cte_t(const cte_t&) = default;
|
||||
cte_t(cte_t&&) = default;
|
||||
cte_t& operator=(const cte_t&) = default;
|
||||
@ -209,7 +213,6 @@ namespace sqlpp
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// The cte_t is displayed as AliasProviderName except within the with:
|
||||
// - the with needs the
|
||||
// AliasProviderName AS (ColumnNames) (select/union)
|
||||
@ -225,12 +228,15 @@ namespace sqlpp
|
||||
using _alias_t = typename AliasProvider::_alias_t;
|
||||
|
||||
template <typename Statement>
|
||||
auto as(Statement statement)
|
||||
-> make_cte_t<AliasProvider, Statement>
|
||||
auto as(Statement statement) -> make_cte_t<AliasProvider, Statement>
|
||||
{
|
||||
static_assert(required_tables_of<Statement>::size::value == 0, "common table expression must not use unknown tables");
|
||||
static_assert(not detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value, "common table expression must not self-reference in the first part, use union_all/union_distinct for recursion");
|
||||
static_assert(is_static_result_row_t<get_result_row_t<Statement>>::value, "ctes must not have dynamically added columns");
|
||||
static_assert(required_tables_of<Statement>::size::value == 0,
|
||||
"common table expression must not use unknown tables");
|
||||
static_assert(not detail::is_element_of<AliasProvider, required_ctes_of<Statement>>::value,
|
||||
"common table expression must not self-reference in the first part, use union_all/union_distinct "
|
||||
"for recursion");
|
||||
static_assert(is_static_result_row_t<get_result_row_t<Statement>>::value,
|
||||
"ctes must not have dynamically added columns");
|
||||
|
||||
return {statement};
|
||||
}
|
||||
@ -250,12 +256,10 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename AliasProvider>
|
||||
auto cte(const AliasProvider&)
|
||||
-> cte_ref_t<AliasProvider>
|
||||
auto cte(const AliasProvider&) -> cte_ref_t<AliasProvider>
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -49,26 +49,26 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template <typename Database, typename... Parts>
|
||||
struct custom_query_t:
|
||||
private detail::custom_parts_t<Database, Parts...>::_result_methods_t
|
||||
struct custom_query_t : private detail::custom_parts_t<Database, Parts...>::_result_methods_t
|
||||
{
|
||||
using _methods_t = typename detail::custom_parts_t<Database, Parts...>::_result_methods_t;
|
||||
using _traits = make_traits<no_value_t, tag::is_statement>;
|
||||
using _nodes = detail::type_vector<Parts...>;
|
||||
|
||||
using _parameter_check = typename std::conditional<detail::type_vector_size<parameters_of<custom_query_t>>::value == 0,
|
||||
consistent_t, assert_no_parameters_t>::type;
|
||||
using _run_check = detail::get_first_if<is_inconsistent_t, consistent_t,
|
||||
_parameter_check>;
|
||||
using _parameter_check =
|
||||
typename std::conditional<detail::type_vector_size<parameters_of<custom_query_t>>::value == 0,
|
||||
consistent_t,
|
||||
assert_no_parameters_t>::type;
|
||||
using _run_check = detail::get_first_if<is_inconsistent_t, consistent_t, _parameter_check>;
|
||||
using _prepare_check = consistent_t;
|
||||
|
||||
custom_query_t(Parts... parts):
|
||||
_parts(parts...)
|
||||
{}
|
||||
custom_query_t(Parts... parts) : _parts(parts...)
|
||||
{
|
||||
}
|
||||
|
||||
custom_query_t(std::tuple<Parts...> parts):
|
||||
_parts(parts)
|
||||
{}
|
||||
custom_query_t(std::tuple<Parts...> parts) : _parts(parts)
|
||||
{
|
||||
}
|
||||
|
||||
custom_query_t(const custom_query_t&) = default;
|
||||
custom_query_t(custom_query_t&&) = default;
|
||||
@ -101,8 +101,7 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template <typename Part>
|
||||
auto with_result_type_of(Part part)
|
||||
-> custom_query_t<Database, Part, Parts...>
|
||||
auto with_result_type_of(Part part) -> custom_query_t<Database, Part, Parts...>
|
||||
{
|
||||
return {tuple_cat(std::make_tuple(part), _parts)};
|
||||
}
|
||||
@ -124,16 +123,14 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename... Parts>
|
||||
auto custom_query(Parts... parts)
|
||||
-> custom_query_t<void, wrap_operand_t<Parts>...>
|
||||
auto custom_query(Parts... parts) -> custom_query_t<void, wrap_operand_t<Parts>...>
|
||||
{
|
||||
static_assert(sizeof...(Parts) > 0, "custom query requires at least one argument");
|
||||
return custom_query_t<void, wrap_operand_t<Parts>...>(parts...);
|
||||
}
|
||||
|
||||
template <typename Database, typename... Parts>
|
||||
auto dynamic_custom_query(const Database&, Parts... parts)
|
||||
-> custom_query_t<Database, wrap_operand_t<Parts>...>
|
||||
auto dynamic_custom_query(const Database&, Parts... parts) -> custom_query_t<Database, wrap_operand_t<Parts>...>
|
||||
{
|
||||
static_assert(sizeof...(Parts) > 0, "custom query requires at least one query argument");
|
||||
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
|
||||
|
@ -36,7 +36,10 @@ namespace sqlpp
|
||||
using _traits = make_traits<no_value_t, tag::is_expression>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
|
||||
static constexpr bool _is_trivial() { return false; }
|
||||
static constexpr bool _is_trivial()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
@ -53,7 +56,6 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
constexpr default_value_t default_value = {};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -40,19 +40,28 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
struct as_column_tuple
|
||||
{
|
||||
static std::tuple<auto_alias_t<T>> _(T t) { return std::tuple<auto_alias_t<T>>(auto_alias_t<T>{t}); }
|
||||
static std::tuple<auto_alias_t<T>> _(T t)
|
||||
{
|
||||
return std::tuple<auto_alias_t<T>>(auto_alias_t<T>{t});
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct as_column_tuple<all_of_t<T>>
|
||||
{
|
||||
static typename all_of_t<T>::_column_tuple_t _(all_of_t<T>) { return { }; }
|
||||
static typename all_of_t<T>::_column_tuple_t _(all_of_t<T>)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
struct as_column_tuple<std::tuple<Args...>>
|
||||
{
|
||||
static std::tuple<auto_alias_t<Args>...> _(std::tuple<Args...> t) { return t; }
|
||||
static std::tuple<auto_alias_t<Args>...> _(std::tuple<Args...> t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename...> class Target, typename First, typename T>
|
||||
@ -75,9 +84,7 @@ namespace sqlpp
|
||||
{
|
||||
return std::tuple_cat(as_column_tuple<Columns>::_(columns)...);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -46,16 +46,29 @@ namespace sqlpp
|
||||
static_assert(wrong_t<make_field_index_sequence_impl>::value, "invalid field index sequence arguments");
|
||||
};
|
||||
|
||||
template<std::size_t NextIndex, std::size_t... Ints, typename NameType, typename ValueType, bool CanBeNull, bool NullIsTrivialValue, typename... Rest>
|
||||
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>, field_spec_t<NameType, ValueType, CanBeNull, NullIsTrivialValue>, Rest...>
|
||||
template <std::size_t NextIndex,
|
||||
std::size_t... Ints,
|
||||
typename NameType,
|
||||
typename ValueType,
|
||||
bool CanBeNull,
|
||||
bool NullIsTrivialValue,
|
||||
typename... Rest>
|
||||
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>,
|
||||
field_spec_t<NameType, ValueType, CanBeNull, NullIsTrivialValue>,
|
||||
Rest...>
|
||||
{
|
||||
using type = typename make_field_index_sequence_impl<field_index_sequence<NextIndex + 1, Ints..., NextIndex>, Rest...>::type;
|
||||
using type = typename make_field_index_sequence_impl<field_index_sequence<NextIndex + 1, Ints..., NextIndex>,
|
||||
Rest...>::type;
|
||||
};
|
||||
|
||||
template <std::size_t NextIndex, std::size_t... Ints, typename AliasProvider, typename FieldTuple, typename... Rest>
|
||||
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>, multi_field_spec_t<AliasProvider, FieldTuple>, Rest...>
|
||||
struct make_field_index_sequence_impl<field_index_sequence<NextIndex, Ints...>,
|
||||
multi_field_spec_t<AliasProvider, FieldTuple>,
|
||||
Rest...>
|
||||
{
|
||||
using type = typename make_field_index_sequence_impl<field_index_sequence<NextIndex + std::tuple_size<FieldTuple>::value, Ints..., NextIndex>, Rest...>::type;
|
||||
using type = typename make_field_index_sequence_impl<
|
||||
field_index_sequence<NextIndex + std::tuple_size<FieldTuple>::value, Ints..., NextIndex>,
|
||||
Rest...>::type;
|
||||
};
|
||||
|
||||
template <std::size_t NextIndex, std::size_t... Ints>
|
||||
@ -65,10 +78,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <std::size_t StartIndex, typename... Fields>
|
||||
using make_field_index_sequence = typename make_field_index_sequence_impl<field_index_sequence<StartIndex>, Fields...>::type;
|
||||
|
||||
using make_field_index_sequence =
|
||||
typename make_field_index_sequence_impl<field_index_sequence<StartIndex>, Fields...>::type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -46,9 +46,7 @@ namespace sqlpp
|
||||
struct get_first_if_impl<Predicate, Default, T, Rest...>
|
||||
{
|
||||
using rest = typename get_first_if_impl<Predicate, Default, Rest...>::type;
|
||||
using type = typename std::conditional<Predicate<T>::value,
|
||||
T,
|
||||
rest>::type;
|
||||
using type = typename std::conditional<Predicate<T>::value, T, rest>::type;
|
||||
};
|
||||
|
||||
template <template <typename> class Predicate, typename Default, typename... T>
|
||||
@ -56,5 +54,4 @@ namespace sqlpp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -46,9 +46,7 @@ namespace sqlpp
|
||||
struct get_last_if_impl<Predicate, Default, T, Rest...>
|
||||
{
|
||||
using rest = typename get_last_if_impl<Predicate, Default, Rest...>::type;
|
||||
using type = typename std::conditional<std::is_same<rest, Default>::value and Predicate<T>::value,
|
||||
T,
|
||||
rest>::type;
|
||||
using type = typename std::conditional<std::is_same<rest, Default>::value and Predicate<T>::value, T, rest>::type;
|
||||
};
|
||||
|
||||
template <template <typename> class Predicate, typename Default, typename... T>
|
||||
@ -56,5 +54,4 @@ namespace sqlpp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -37,7 +37,8 @@ namespace sqlpp
|
||||
// It should be replaced once the project is moved to C++14 or beyond
|
||||
template <std::size_t... Ints>
|
||||
struct index_sequence
|
||||
{};
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
struct make_index_sequence_impl;
|
||||
@ -56,9 +57,7 @@ namespace sqlpp
|
||||
|
||||
template <std::size_t N>
|
||||
using make_index_sequence = typename make_index_sequence_impl<index_sequence<>, N>::type;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -54,5 +54,4 @@ namespace sqlpp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -31,7 +31,6 @@ namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/** a non-recursive C++14 version
|
||||
template<typename... Args>
|
||||
constexpr std::size_t sum(Args... args)
|
||||
@ -59,4 +58,3 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -52,14 +52,14 @@ namespace sqlpp
|
||||
using size = std::integral_constant<size_t, sizeof...(Elements)>;
|
||||
using _is_type_set = std::true_type;
|
||||
|
||||
static_assert(std::is_same<type_set, make_type_set_t<Elements...>>::value, "use make_type_set to construct a typeset");
|
||||
static_assert(std::is_same<type_set, make_type_set_t<Elements...>>::value,
|
||||
"use make_type_set to construct a typeset");
|
||||
|
||||
template <typename T>
|
||||
struct insert
|
||||
{
|
||||
using type = typename std::conditional<not is_element_of<T, type_set>::value,
|
||||
type_set<T, Elements...>,
|
||||
type_set>::type;
|
||||
using type =
|
||||
typename std::conditional<not is_element_of<T, type_set>::value, type_set<T, Elements...>, type_set>::type;
|
||||
};
|
||||
|
||||
template <template <typename A> class Predicate, typename T>
|
||||
@ -71,7 +71,6 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <typename E, typename SET>
|
||||
struct is_element_of
|
||||
{
|
||||
@ -108,7 +107,8 @@ namespace sqlpp
|
||||
template <typename... LElements, typename... RElements>
|
||||
struct is_superset_of<type_set<LElements...>, type_set<RElements...>>
|
||||
{
|
||||
static constexpr bool value = joined_set_t<type_set<LElements...>, type_set<RElements...>>::size::value == sizeof...(LElements);
|
||||
static constexpr bool value =
|
||||
joined_set_t<type_set<LElements...>, type_set<RElements...>>::size::value == sizeof...(LElements);
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
@ -126,7 +126,8 @@ namespace sqlpp
|
||||
template <typename... LElements, typename... RElements>
|
||||
struct is_disjunct_from<type_set<LElements...>, type_set<RElements...>>
|
||||
{
|
||||
static constexpr bool value = joined_set_t<type_set<LElements...>, type_set<RElements...>>::size::value == sizeof...(LElements) + sizeof...(RElements);
|
||||
static constexpr bool value = joined_set_t<type_set<LElements...>, type_set<RElements...>>::size::value ==
|
||||
sizeof...(LElements) + sizeof...(RElements);
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -223,14 +224,14 @@ namespace sqlpp
|
||||
struct make_intersect_set<type_set<LhsElements...>, type_set<RhsElements...>>
|
||||
{
|
||||
template <typename E>
|
||||
using is_in_both = ::sqlpp::logic::all_t<is_element_of<E, type_set<LhsElements...>>::value, is_element_of<E, type_set<RhsElements...>>::value>;
|
||||
using is_in_both = ::sqlpp::logic::all_t<is_element_of<E, type_set<LhsElements...>>::value,
|
||||
is_element_of<E, type_set<RhsElements...>>::value>;
|
||||
using type = make_type_set_if_t<is_in_both, LhsElements...>;
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
using make_intersect_set_t = typename make_intersect_set<Lhs, Rhs>::type;
|
||||
|
||||
|
||||
template <template <typename> class Transformation, typename T>
|
||||
struct transform_set
|
||||
{
|
||||
@ -245,11 +246,7 @@ namespace sqlpp
|
||||
|
||||
template <template <typename> class Transformation, typename T>
|
||||
using transform_set_t = typename transform_set<Transformation, T>::type;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,8 @@ namespace sqlpp
|
||||
{
|
||||
template <typename... T>
|
||||
struct type_vector
|
||||
{};
|
||||
{
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
struct type_vector_cat_impl
|
||||
@ -73,7 +74,8 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
struct type_vector_size
|
||||
{
|
||||
static_assert(wrong_t<type_vector_size>::value, "type_vector_size needs to be called with a type_vector argument");
|
||||
static_assert(wrong_t<type_vector_size>::value,
|
||||
"type_vector_size needs to be called with a type_vector argument");
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
@ -84,5 +86,4 @@ namespace sqlpp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -38,15 +38,19 @@ namespace sqlpp
|
||||
struct eval_t
|
||||
{
|
||||
static_assert(is_database<Db>::value, "Db parameter of eval has to be a database connection");
|
||||
static_assert(is_expression_t<Expr>::value, "Expression parameter of eval has to be an sqlpp expression or a string");
|
||||
static_assert(required_tables_of<Expr>::size::value == 0, "Expression cannot be used in eval because it requires tables");
|
||||
static_assert(is_expression_t<Expr>::value,
|
||||
"Expression parameter of eval has to be an sqlpp expression or a string");
|
||||
static_assert(required_tables_of<Expr>::size::value == 0,
|
||||
"Expression cannot be used in eval because it requires tables");
|
||||
using _name_type = alias::a_t::_alias_t;
|
||||
using _value_type = value_type_of<Expr>;
|
||||
using _field_spec = field_spec_t<_name_type, _value_type, true, false>;
|
||||
using type = result_field_t<_value_type, Db, _field_spec>;
|
||||
};
|
||||
|
||||
template<typename Db, typename Expr, typename std::enable_if<not std::is_convertible<Expr, std::string>::value, int>::type = 0>
|
||||
template <typename Db,
|
||||
typename Expr,
|
||||
typename std::enable_if<not std::is_convertible<Expr, std::string>::value, int>::type = 0>
|
||||
auto eval(Db& db, Expr expr) -> typename eval_t<Db, Expr>::type
|
||||
{
|
||||
return db(select(expr.as(alias::a))).front().a;
|
||||
|
@ -34,10 +34,13 @@ namespace sqlpp
|
||||
class exception : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
exception(const std::string& what_arg): std::runtime_error(what_arg) {}
|
||||
exception(const char* what_arg): std::runtime_error(what_arg) {}
|
||||
exception(const std::string& what_arg) : std::runtime_error(what_arg)
|
||||
{
|
||||
}
|
||||
exception(const char* what_arg) : std::runtime_error(what_arg)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -42,16 +42,20 @@ namespace sqlpp
|
||||
struct _member_t
|
||||
{
|
||||
T exists;
|
||||
T& operator()() { return exists; }
|
||||
const T& operator()() const { return exists; }
|
||||
T& operator()()
|
||||
{
|
||||
return exists;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return exists;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Select>
|
||||
struct exists_t:
|
||||
public expression_operators<exists_t<Select>, boolean>,
|
||||
public alias_operators<exists_t<Select>>
|
||||
struct exists_t : public expression_operators<exists_t<Select>, boolean>, public alias_operators<exists_t<Select>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Select>;
|
||||
@ -60,9 +64,9 @@ namespace sqlpp
|
||||
|
||||
using _auto_alias_t = exists_alias_t;
|
||||
|
||||
exists_t(Select select):
|
||||
_select(select)
|
||||
{}
|
||||
exists_t(Select select) : _select(select)
|
||||
{
|
||||
}
|
||||
|
||||
exists_t(const exists_t&) = default;
|
||||
exists_t(exists_t&&) = default;
|
||||
@ -88,14 +92,12 @@ namespace sqlpp
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
auto exists(T t) -> exists_t<wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(is_select_t<wrap_operand_t<T>>::value, "exists() requires a select expression as argument");
|
||||
return {t};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -39,8 +39,8 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct binary_expression_t<Lhs, op::equal_to, Rhs>:
|
||||
public expression_operators<binary_expression_t<Lhs, op::equal_to, Rhs>, boolean>,
|
||||
struct binary_expression_t<Lhs, op::equal_to, Rhs>
|
||||
: public expression_operators<binary_expression_t<Lhs, op::equal_to, Rhs>, boolean>,
|
||||
public alias_operators<binary_expression_t<Lhs, op::equal_to, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression>;
|
||||
@ -48,10 +48,9 @@ namespace sqlpp
|
||||
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
|
||||
using _nodes = detail::type_vector<_lhs_t, _rhs_t>;
|
||||
|
||||
binary_expression_t(_lhs_t lhs, _rhs_t rhs):
|
||||
_lhs(lhs),
|
||||
_rhs(rhs)
|
||||
{}
|
||||
binary_expression_t(_lhs_t lhs, _rhs_t rhs) : _lhs(lhs), _rhs(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
binary_expression_t(const binary_expression_t&) = default;
|
||||
binary_expression_t(binary_expression_t&&) = default;
|
||||
@ -88,8 +87,8 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct binary_expression_t<Lhs, op::not_equal_to, Rhs>:
|
||||
public expression_operators<binary_expression_t<Lhs, op::not_equal_to, Rhs>, boolean>,
|
||||
struct binary_expression_t<Lhs, op::not_equal_to, Rhs>
|
||||
: public expression_operators<binary_expression_t<Lhs, op::not_equal_to, Rhs>, boolean>,
|
||||
public alias_operators<binary_expression_t<Lhs, op::not_equal_to, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression>;
|
||||
@ -97,10 +96,9 @@ namespace sqlpp
|
||||
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
|
||||
using _nodes = detail::type_vector<_lhs_t, _rhs_t>;
|
||||
|
||||
binary_expression_t(Lhs lhs, _rhs_t rhs):
|
||||
_lhs(lhs),
|
||||
_rhs(rhs)
|
||||
{}
|
||||
binary_expression_t(Lhs lhs, _rhs_t rhs) : _lhs(lhs), _rhs(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
binary_expression_t(const binary_expression_t&) = default;
|
||||
binary_expression_t(binary_expression_t&&) = default;
|
||||
@ -137,16 +135,16 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Rhs>
|
||||
struct unary_expression_t<op::logical_not, Rhs>:
|
||||
public expression_operators<unary_expression_t<op::logical_not, Rhs>, boolean>,
|
||||
struct unary_expression_t<op::logical_not, Rhs>
|
||||
: public expression_operators<unary_expression_t<op::logical_not, Rhs>, boolean>,
|
||||
public alias_operators<unary_expression_t<op::logical_not, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression>;
|
||||
using _nodes = detail::type_vector<Rhs>;
|
||||
|
||||
unary_expression_t(Rhs rhs):
|
||||
_rhs(rhs)
|
||||
{}
|
||||
unary_expression_t(Rhs rhs) : _rhs(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
unary_expression_t(const unary_expression_t&) = default;
|
||||
unary_expression_t(unary_expression_t&&) = default;
|
||||
@ -183,17 +181,15 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Lhs, typename O, typename Rhs>
|
||||
struct binary_expression_t:
|
||||
public expression_operators<binary_expression_t<Lhs, O, Rhs>, value_type_of<O>>,
|
||||
struct binary_expression_t : public expression_operators<binary_expression_t<Lhs, O, Rhs>, value_type_of<O>>,
|
||||
public alias_operators<binary_expression_t<Lhs, O, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<value_type_of<O>, tag::is_expression>;
|
||||
using _nodes = detail::type_vector<Lhs, Rhs>;
|
||||
|
||||
binary_expression_t(Lhs lhs, Rhs rhs):
|
||||
_lhs(lhs),
|
||||
_rhs(rhs)
|
||||
{}
|
||||
binary_expression_t(Lhs lhs, Rhs rhs) : _lhs(lhs), _rhs(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
binary_expression_t(const binary_expression_t&) = default;
|
||||
binary_expression_t(binary_expression_t&&) = default;
|
||||
@ -223,16 +219,15 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename O, typename Rhs>
|
||||
struct unary_expression_t:
|
||||
public expression_operators<unary_expression_t<O, Rhs>, value_type_of<O>>,
|
||||
struct unary_expression_t : public expression_operators<unary_expression_t<O, Rhs>, value_type_of<O>>,
|
||||
public alias_operators<unary_expression_t<O, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<value_type_of<O>, tag::is_expression>;
|
||||
using _nodes = detail::type_vector<Rhs>;
|
||||
|
||||
unary_expression_t(Rhs rhs):
|
||||
_rhs(rhs)
|
||||
{}
|
||||
unary_expression_t(Rhs rhs) : _rhs(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
unary_expression_t(const unary_expression_t&) = default;
|
||||
unary_expression_t(unary_expression_t&&) = default;
|
||||
|
@ -146,7 +146,6 @@ namespace sqlpp
|
||||
using _traits = make_traits<ValueType>;
|
||||
static constexpr const char* _name = "|";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename Lhs, typename O, typename Rhs>
|
||||
|
@ -37,14 +37,14 @@ namespace sqlpp
|
||||
struct extra_tables_data_t
|
||||
{
|
||||
extra_tables_data_t()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
extra_tables_data_t(const extra_tables_data_t&) = default;
|
||||
extra_tables_data_t(extra_tables_data_t&&) = default;
|
||||
extra_tables_data_t& operator=(const extra_tables_data_t&) = default;
|
||||
extra_tables_data_t& operator=(extra_tables_data_t&&) = default;
|
||||
~extra_tables_data_t() = default;
|
||||
|
||||
};
|
||||
|
||||
// EXTRA_TABLES
|
||||
@ -73,8 +73,14 @@ namespace sqlpp
|
||||
using _data_t = extra_tables_data_t<Tables...>;
|
||||
|
||||
_impl_t<Policies> extra_tables;
|
||||
_impl_t<Policies>& operator()() { return extra_tables; }
|
||||
const _impl_t<Policies>& operator()() const { return extra_tables; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return extra_tables;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return extra_tables;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.extra_tables)
|
||||
@ -109,8 +115,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_extra_tables;
|
||||
_impl_t<Policies>& operator()() { return no_extra_tables; }
|
||||
const _impl_t<Policies>& operator()() const { return no_extra_tables; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_extra_tables;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_extra_tables;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_extra_tables)
|
||||
@ -127,8 +139,7 @@ namespace sqlpp
|
||||
using _consistency_check = consistent_t;
|
||||
|
||||
template <typename... Tables>
|
||||
auto extra_tables(Tables... tables) const
|
||||
-> _new_statement_t<_check<Tables...>, extra_tables_t<Tables...>>
|
||||
auto extra_tables(Tables... tables) const -> _new_statement_t<_check<Tables...>, extra_tables_t<Tables...>>
|
||||
{
|
||||
static_assert(_check<Tables...>::value, "at least one argument is not a table or join in extra_tables()");
|
||||
|
||||
@ -137,20 +148,22 @@ namespace sqlpp
|
||||
|
||||
private:
|
||||
template <typename Database, typename... Tables>
|
||||
auto _extra_tables_impl(const std::false_type&, Tables... tables) const
|
||||
-> bad_statement;
|
||||
auto _extra_tables_impl(const std::false_type&, Tables... tables) const -> bad_statement;
|
||||
|
||||
template <typename Database, typename... Tables>
|
||||
auto _extra_tables_impl(const std::true_type&, Tables...) const
|
||||
-> _new_statement_t<std::true_type, extra_tables_t<Tables...>>
|
||||
{
|
||||
static_assert(required_tables_of<extra_tables_t<Tables...>>::size::value == 0, "at least one table depends on another table in extra_tables()");
|
||||
static_assert(required_tables_of<extra_tables_t<Tables...>>::size::value == 0,
|
||||
"at least one table depends on another table in extra_tables()");
|
||||
|
||||
static constexpr std::size_t _number_of_tables = detail::sum(provided_tables_of<Tables>::size::value...);
|
||||
using _unique_tables = detail::make_joined_set_t<provided_tables_of<Tables>...>;
|
||||
using _unique_table_names = detail::transform_set_t<name_of, _unique_tables>;
|
||||
static_assert(_number_of_tables == _unique_tables::size::value, "at least one duplicate table detected in extra_tables()");
|
||||
static_assert(_number_of_tables == _unique_table_names::size::value, "at least one duplicate table name detected in extra_tables()");
|
||||
static_assert(_number_of_tables == _unique_tables::size::value,
|
||||
"at least one duplicate table detected in extra_tables()");
|
||||
static_assert(_number_of_tables == _unique_table_names::size::value,
|
||||
"at least one duplicate table name detected in extra_tables()");
|
||||
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), extra_tables_data_t<Tables...>{}};
|
||||
}
|
||||
@ -169,7 +182,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -34,10 +34,10 @@ namespace sqlpp
|
||||
template <typename NameType, typename ValueType, bool CanBeNull, bool NullIsTrivialValue>
|
||||
struct field_spec_t
|
||||
{
|
||||
using _traits = make_traits<ValueType, tag::is_noop,
|
||||
using _traits = make_traits<ValueType,
|
||||
tag::is_noop,
|
||||
tag_if<tag::can_be_null, CanBeNull>,
|
||||
tag_if<tag::null_is_trivial_value, NullIsTrivialValue>
|
||||
>;
|
||||
tag_if<tag::null_is_trivial_value, NullIsTrivialValue>>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
|
||||
using _alias_t = NameType;
|
||||
@ -54,7 +54,9 @@ namespace sqlpp
|
||||
struct make_field_spec_impl
|
||||
{
|
||||
static constexpr bool _can_be_null = can_be_null_t<NamedExpr>::value;
|
||||
static constexpr bool _depends_on_outer_table = detail::make_intersect_set_t<required_tables_of<NamedExpr>, typename Select::_used_outer_tables>::size::value > 0;
|
||||
static constexpr bool _depends_on_outer_table =
|
||||
detail::make_intersect_set_t<required_tables_of<NamedExpr>,
|
||||
typename Select::_used_outer_tables>::size::value > 0;
|
||||
|
||||
using type = field_spec_t<typename NamedExpr::_alias_t,
|
||||
value_type_of<NamedExpr>,
|
||||
@ -65,13 +67,13 @@ namespace sqlpp
|
||||
template <typename Select, typename AliasProvider, typename... NamedExprs>
|
||||
struct make_field_spec_impl<Select, multi_column_alias_t<AliasProvider, NamedExprs...>>
|
||||
{
|
||||
using type = multi_field_spec_t<AliasProvider, std::tuple<typename make_field_spec_impl<Select, NamedExprs>::type...>>;
|
||||
using type =
|
||||
multi_field_spec_t<AliasProvider, std::tuple<typename make_field_spec_impl<Select, NamedExprs>::type...>>;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Select, typename NamedExpr>
|
||||
using make_field_spec_t = typename detail::make_field_spec_impl<Select, NamedExpr>::type;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -53,15 +53,13 @@ namespace sqlpp
|
||||
using _value_type = floating_point;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t():
|
||||
_value(0),
|
||||
_is_null(true)
|
||||
{}
|
||||
parameter_value_t() : _value(0), _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t(const _cpp_value_type& val):
|
||||
_value(val),
|
||||
_is_null(false)
|
||||
{}
|
||||
parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
@ -102,7 +100,10 @@ namespace sqlpp
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const { return _value; }
|
||||
operator _cpp_value_type() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
@ -117,8 +118,7 @@ namespace sqlpp
|
||||
|
||||
// floating_point expression operators
|
||||
template <typename Expr>
|
||||
struct expression_operators<Expr, floating_point>:
|
||||
public basic_expression_operators<Expr, floating_point>
|
||||
struct expression_operators<Expr, floating_point> : public basic_expression_operators<Expr, floating_point>
|
||||
{
|
||||
template <typename T>
|
||||
using _is_valid_operand = is_valid_operand<floating_point, T>;
|
||||
@ -213,16 +213,15 @@ namespace sqlpp
|
||||
};
|
||||
// floating_point result field
|
||||
template <typename Db, typename FieldSpec>
|
||||
struct result_field_t<floating_point, Db, FieldSpec>: public result_field_methods_t<result_field_t<floating_point, Db, FieldSpec>>
|
||||
struct result_field_t<floating_point, Db, FieldSpec>
|
||||
: public result_field_methods_t<result_field_t<floating_point, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, floating_point>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename floating_point::_cpp_value_type;
|
||||
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
_is_null(true),
|
||||
_value(0)
|
||||
{}
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value(0)
|
||||
{
|
||||
}
|
||||
|
||||
void _validate()
|
||||
{
|
||||
@ -287,6 +286,5 @@ namespace sqlpp
|
||||
{
|
||||
return serialize(e, os);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -42,9 +42,9 @@ namespace sqlpp
|
||||
template <typename Database, typename... Tables>
|
||||
struct from_data_t
|
||||
{
|
||||
from_data_t(Tables... tables):
|
||||
_tables(tables...)
|
||||
{}
|
||||
from_data_t(Tables... tables) : _tables(tables...)
|
||||
{
|
||||
}
|
||||
|
||||
from_data_t(const from_data_t&) = default;
|
||||
from_data_t(from_data_t&&) = default;
|
||||
@ -76,9 +76,11 @@ namespace sqlpp
|
||||
{
|
||||
static_assert(_is_dynamic::value, "from::add() must not be called for static from()");
|
||||
static_assert(is_table_t<Table>::value, "invalid table argument in from::add()");
|
||||
using _known_tables = detail::make_joined_set_t<provided_tables_of<Tables>...>; // Hint: Joins contain more than one table
|
||||
using _known_tables =
|
||||
detail::make_joined_set_t<provided_tables_of<Tables>...>; // Hint: Joins contain more than one table
|
||||
using _known_table_names = detail::transform_set_t<name_of, _known_tables>;
|
||||
static_assert(not detail::is_element_of<typename Table::_alias_t, _known_table_names>::value, "Must not use the same table name twice in from()");
|
||||
static_assert(not detail::is_element_of<typename Table::_alias_t, _known_table_names>::value,
|
||||
"Must not use the same table name twice in from()");
|
||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Table>;
|
||||
_serialize_check::_();
|
||||
|
||||
@ -108,8 +110,14 @@ namespace sqlpp
|
||||
using _data_t = from_data_t<Database, Tables...>;
|
||||
|
||||
_impl_t<Policies> from;
|
||||
_impl_t<Policies>& operator()() { return from; }
|
||||
const _impl_t<Policies>& operator()() const { return from; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return from;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return from;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.from)
|
||||
@ -144,8 +152,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_from;
|
||||
_impl_t<Policies>& operator()() { return no_from; }
|
||||
const _impl_t<Policies>& operator()() const { return no_from; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_from;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_from;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_from)
|
||||
@ -164,8 +178,7 @@ namespace sqlpp
|
||||
using _consistency_check = consistent_t;
|
||||
|
||||
template <typename... Tables>
|
||||
auto from(Tables... tables) const
|
||||
-> _new_statement_t<_check<Tables...>, from_t<void, from_table_t<Tables>...>>
|
||||
auto from(Tables... tables) const -> _new_statement_t<_check<Tables...>, from_t<void, from_table_t<Tables>...>>
|
||||
{
|
||||
static_assert(_check<Tables...>::value, "at least one argument is not a table or join in from()");
|
||||
static_assert(sizeof...(Tables), "at least one table or join argument required in from()");
|
||||
@ -176,31 +189,34 @@ namespace sqlpp
|
||||
auto dynamic_from(Tables... tables) const
|
||||
-> _new_statement_t<_check<Tables...>, from_t<_database_t, from_table_t<Tables>...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_from must not be called in a static statement");
|
||||
static_assert(not std::is_same<_database_t, void>::value,
|
||||
"dynamic_from must not be called in a static statement");
|
||||
static_assert(_check<Tables...>::value, "at least one argument is not a table or join in from()");
|
||||
return _from_impl<_database_t>(_check<Tables...>{}, tables...);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Database, typename... Tables>
|
||||
auto _from_impl(const std::false_type&, Tables... tables) const
|
||||
-> bad_statement;
|
||||
auto _from_impl(const std::false_type&, Tables... tables) const -> bad_statement;
|
||||
|
||||
template <typename Database, typename... Tables>
|
||||
auto _from_impl(const std::true_type&, Tables... tables) const
|
||||
-> _new_statement_t<std::true_type, from_t<Database, from_table_t<Tables>...>>
|
||||
{
|
||||
static_assert(required_tables_of<from_t<Database, Tables...>>::size::value == 0, "at least one table depends on another table in from()");
|
||||
static_assert(required_tables_of<from_t<Database, Tables...>>::size::value == 0,
|
||||
"at least one table depends on another table in from()");
|
||||
|
||||
static constexpr std::size_t _number_of_tables = detail::sum(provided_tables_of<Tables>::size::value...);
|
||||
using _unique_tables = detail::make_joined_set_t<provided_tables_of<Tables>...>;
|
||||
using _unique_table_names = detail::transform_set_t<name_of, _unique_tables>;
|
||||
static_assert(_number_of_tables == _unique_tables::size::value, "at least one duplicate table detected in from()");
|
||||
static_assert(_number_of_tables == _unique_table_names::size::value, "at least one duplicate table name detected in from()");
|
||||
static_assert(_number_of_tables == _unique_tables::size::value,
|
||||
"at least one duplicate table detected in from()");
|
||||
static_assert(_number_of_tables == _unique_table_names::size::value,
|
||||
"at least one duplicate table name detected in from()");
|
||||
|
||||
return { static_cast<const derived_statement_t<Policies>&>(*this), from_data_t<Database, from_table_t<Tables>...>{from_table(tables)...} };
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
||||
from_data_t<Database, from_table_t<Tables>...>{from_table(tables)...}};
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -54,14 +54,16 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
auto value(T t) -> wrap_operand_t<T>
|
||||
{
|
||||
static_assert(is_wrapped_value_t<wrap_operand_t<T>>::value, "value() is to be called with non-sql-type like int, or string");
|
||||
static_assert(is_wrapped_value_t<wrap_operand_t<T>>::value,
|
||||
"value() is to be called with non-sql-type like int, or string");
|
||||
return {t};
|
||||
}
|
||||
|
||||
template <typename Expression, typename Db>
|
||||
auto flatten(const Expression& exp, Db& db) -> verbatim_t<value_type_of<Expression>>
|
||||
{
|
||||
static_assert(not make_parameter_list_t<Expression>::size::value, "parameters are not allowed in flattened expressions");
|
||||
static_assert(not make_parameter_list_t<Expression>::size::value,
|
||||
"parameters are not allowed in flattened expressions");
|
||||
auto context = db.get_serializer_context();
|
||||
serialize(exp, context);
|
||||
return {context.str()};
|
||||
@ -87,9 +89,9 @@ namespace sqlpp
|
||||
|
||||
using _container_t = Container;
|
||||
|
||||
value_list_t(_container_t container):
|
||||
_container(container)
|
||||
{}
|
||||
value_list_t(_container_t container) : _container(container)
|
||||
{
|
||||
}
|
||||
|
||||
value_list_t(const value_list_t&) = default;
|
||||
value_list_t(value_list_t&&) = default;
|
||||
@ -130,7 +132,9 @@ namespace sqlpp
|
||||
template <typename Container>
|
||||
auto value_list(Container c) -> value_list_t<Container>
|
||||
{
|
||||
static_assert(is_wrapped_value_t<wrap_operand_t<typename Container::value_type>>::value, "value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)");
|
||||
static_assert(
|
||||
is_wrapped_value_t<wrap_operand_t<typename Container::value_type>>::value,
|
||||
"value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)");
|
||||
return {c};
|
||||
}
|
||||
|
||||
@ -139,8 +143,6 @@ namespace sqlpp
|
||||
{
|
||||
return name_of<T>::char_ptr();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,9 +41,9 @@ namespace sqlpp
|
||||
template <typename Database, typename... Expressions>
|
||||
struct group_by_data_t
|
||||
{
|
||||
group_by_data_t(Expressions... expressions):
|
||||
_expressions(expressions...)
|
||||
{}
|
||||
group_by_data_t(Expressions... expressions) : _expressions(expressions...)
|
||||
{
|
||||
}
|
||||
|
||||
group_by_data_t(const group_by_data_t&) = default;
|
||||
group_by_data_t(group_by_data_t&&) = default;
|
||||
@ -62,7 +62,8 @@ namespace sqlpp
|
||||
template <typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one group-by expression requires a table which is otherwise not known in the statement");
|
||||
static_assert(wrong_t<T>::value,
|
||||
"at least one group-by expression requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,7 +94,8 @@ namespace sqlpp
|
||||
{
|
||||
static_assert(_is_dynamic::value, "add() must not be called for static group_by");
|
||||
static_assert(is_expression_t<Expression>::value, "invalid expression argument in group_by::add()");
|
||||
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value, "expression uses tables unknown to this statement in group_by::add()");
|
||||
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value,
|
||||
"expression uses tables unknown to this statement in group_by::add()");
|
||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expression>;
|
||||
_serialize_check::_();
|
||||
|
||||
@ -111,6 +113,7 @@ namespace sqlpp
|
||||
|
||||
template <typename Expression>
|
||||
void _add_impl(Expression expression, const std::false_type&);
|
||||
|
||||
public:
|
||||
_data_t _data;
|
||||
};
|
||||
@ -122,8 +125,14 @@ namespace sqlpp
|
||||
using _data_t = group_by_data_t<Database, Expressions...>;
|
||||
|
||||
_impl_t<Policies> group_by;
|
||||
_impl_t<Policies>& operator()() { return group_by; }
|
||||
const _impl_t<Policies>& operator()() const { return group_by; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return group_by;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return group_by;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.group_by)
|
||||
@ -160,8 +169,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_group_by;
|
||||
_impl_t<Policies>& operator()() { return no_group_by; }
|
||||
const _impl_t<Policies>& operator()() const { return no_group_by; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_group_by;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_group_by;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_group_by)
|
||||
@ -193,7 +208,8 @@ namespace sqlpp
|
||||
auto dynamic_group_by(Expressions... expressions) const
|
||||
-> _new_statement_t<_check<Expressions...>, group_by_t<_database_t, Expressions...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_group_by must not be called in a static statement");
|
||||
static_assert(not std::is_same<_database_t, void>::value,
|
||||
"dynamic_group_by must not be called in a static statement");
|
||||
static_assert(_check<Expressions...>::value, "at least one argument is not an expression in group_by()");
|
||||
|
||||
return _group_by_impl<_database_t>(_check<Expressions...>{}, expressions...);
|
||||
@ -201,16 +217,17 @@ namespace sqlpp
|
||||
|
||||
private:
|
||||
template <typename Database, typename... Expressions>
|
||||
auto _group_by_impl(const std::false_type&, Expressions... expressions) const
|
||||
-> bad_statement;
|
||||
auto _group_by_impl(const std::false_type&, Expressions... expressions) const -> bad_statement;
|
||||
|
||||
template <typename Database, typename... Expressions>
|
||||
auto _group_by_impl(const std::true_type&, Expressions... expressions) const
|
||||
-> _new_statement_t<std::true_type, group_by_t<_database_t, Expressions...>>
|
||||
{
|
||||
static_assert(not detail::has_duplicates<Expressions...>::value, "at least one duplicate argument detected in group_by()");
|
||||
static_assert(not detail::has_duplicates<Expressions...>::value,
|
||||
"at least one duplicate argument detected in group_by()");
|
||||
|
||||
return { static_cast<const derived_statement_t<Policies>&>(*this), group_by_data_t<Database, Expressions...>{expressions...} };
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
||||
group_by_data_t<Database, Expressions...>{expressions...}};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -40,9 +40,9 @@ namespace sqlpp
|
||||
template <typename Database, typename... Expressions>
|
||||
struct having_data_t
|
||||
{
|
||||
having_data_t(Expressions... expressions):
|
||||
_expressions(expressions...)
|
||||
{}
|
||||
having_data_t(Expressions... expressions) : _expressions(expressions...)
|
||||
{
|
||||
}
|
||||
|
||||
having_data_t(const having_data_t&) = default;
|
||||
having_data_t(having_data_t&&) = default;
|
||||
@ -61,7 +61,8 @@ namespace sqlpp
|
||||
template <typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one having-expression requires a table which is otherwise not known in the statement");
|
||||
static_assert(wrong_t<T>::value,
|
||||
"at least one having-expression requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
@ -92,7 +93,8 @@ namespace sqlpp
|
||||
{
|
||||
static_assert(_is_dynamic::value, "having::add() can only be called for dynamic_having");
|
||||
static_assert(is_expression_t<Expression>::value, "invalid expression argument in having::add()");
|
||||
static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value, "expression uses tables unknown to this statement in having::add()");
|
||||
static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value,
|
||||
"expression uses tables unknown to this statement in having::add()");
|
||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expression>;
|
||||
_serialize_check::_();
|
||||
|
||||
@ -122,8 +124,14 @@ namespace sqlpp
|
||||
using _data_t = having_data_t<Database, Expressions...>;
|
||||
|
||||
_impl_t<Policies> having;
|
||||
_impl_t<Policies>& operator()() { return having; }
|
||||
const _impl_t<Policies>& operator()() const { return having; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return having;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return having;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.having)
|
||||
@ -160,8 +168,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_having;
|
||||
_impl_t<Policies>& operator()() { return no_having; }
|
||||
const _impl_t<Policies>& operator()() const { return no_having; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_having;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_having;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_having)
|
||||
@ -194,22 +208,22 @@ namespace sqlpp
|
||||
-> _new_statement_t<_check<Expressions...>, having_t<_database_t, Expressions...>>
|
||||
{
|
||||
static_assert(_check<Expressions...>::value, "at least one argument is not an expression in having()");
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_having must not be called in a static statement");
|
||||
static_assert(not std::is_same<_database_t, void>::value,
|
||||
"dynamic_having must not be called in a static statement");
|
||||
return _having_impl<_database_t>(_check<Expressions...>{}, expressions...);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Database, typename... Expressions>
|
||||
auto _having_impl(const std::false_type&, Expressions... expressions) const
|
||||
-> bad_statement;
|
||||
auto _having_impl(const std::false_type&, Expressions... expressions) const -> bad_statement;
|
||||
|
||||
template <typename Database, typename... Expressions>
|
||||
auto _having_impl(const std::true_type&, Expressions... expressions) const
|
||||
-> _new_statement_t<std::true_type, having_t<Database, Expressions...>>
|
||||
{
|
||||
return { static_cast<const derived_statement_t<Policies>&>(*this), having_data_t<_database_t, Expressions...>{expressions...} };
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
||||
having_data_t<_database_t, Expressions...>{expressions...}};
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -30,12 +30,11 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Part>
|
||||
struct hidden_t:
|
||||
public Part
|
||||
struct hidden_t : public Part
|
||||
{
|
||||
hidden_t(Part part):
|
||||
Part(part)
|
||||
{}
|
||||
hidden_t(Part part) : Part(part)
|
||||
{
|
||||
}
|
||||
|
||||
hidden_t(const hidden_t&) = default;
|
||||
hidden_t(hidden_t&&) = default;
|
||||
@ -57,8 +56,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Part>
|
||||
auto hidden(Part part)
|
||||
-> hidden_t<Part>
|
||||
auto hidden(Part part) -> hidden_t<Part>
|
||||
{
|
||||
return {part};
|
||||
}
|
||||
|
@ -50,8 +50,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Operand, typename... Args>
|
||||
struct in_t:
|
||||
public expression_operators<in_t<Operand, Args...>, boolean>,
|
||||
struct in_t : public expression_operators<in_t<Operand, Args...>, boolean>,
|
||||
public alias_operators<in_t<Operand, Args...>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression, tag::is_selectable>;
|
||||
@ -61,10 +60,9 @@ namespace sqlpp
|
||||
|
||||
using _auto_alias_t = in_alias_t;
|
||||
|
||||
in_t(Operand operand, Args... args):
|
||||
_operand(operand),
|
||||
_args(args...)
|
||||
{}
|
||||
in_t(Operand operand, Args... args) : _operand(operand), _args(args...)
|
||||
{
|
||||
}
|
||||
|
||||
in_t(const in_t&) = default;
|
||||
in_t(in_t&&) = default;
|
||||
@ -121,7 +119,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -33,7 +33,6 @@ namespace sqlpp
|
||||
struct in_t;
|
||||
template <typename Operand, typename... Args>
|
||||
struct not_in_t;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -39,12 +39,16 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct insert_name_t {};
|
||||
struct insert_name_t
|
||||
{
|
||||
};
|
||||
|
||||
struct insert_t : public statement_name_t<insert_name_t>
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::is_return_value>;
|
||||
struct _alias_t {};
|
||||
struct _alias_t
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Statement>
|
||||
struct _result_methods_t
|
||||
@ -58,8 +62,7 @@ namespace sqlpp
|
||||
|
||||
// Execute
|
||||
template <typename Db, typename Composite>
|
||||
auto _run(Db& db, const Composite& composite) const
|
||||
-> decltype(db.insert(composite))
|
||||
auto _run(Db& db, const Composite& composite) const -> decltype(db.insert(composite))
|
||||
{
|
||||
return db.insert(composite);
|
||||
}
|
||||
@ -72,15 +75,13 @@ namespace sqlpp
|
||||
|
||||
// Prepare
|
||||
template <typename Db, typename Composite>
|
||||
auto _prepare(Db& db, const Composite& composite) const
|
||||
-> prepared_insert_t<Db, Composite>
|
||||
auto _prepare(Db& db, const Composite& composite) const -> prepared_insert_t<Db, Composite>
|
||||
{
|
||||
return {{}, db.prepare_insert(composite)};
|
||||
}
|
||||
|
||||
template <typename Db>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_insert_t<Db, _statement_t>
|
||||
auto _prepare(Db& db) const -> prepared_insert_t<Db, _statement_t>
|
||||
{
|
||||
return {{}, db.prepare_insert(_get_statement())};
|
||||
}
|
||||
@ -102,35 +103,28 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Database>
|
||||
using blank_insert_t = statement_t<Database,
|
||||
insert_t,
|
||||
no_into_t,
|
||||
no_insert_value_list_t>;
|
||||
using blank_insert_t = statement_t<Database, insert_t, no_into_t, no_insert_value_list_t>;
|
||||
|
||||
inline auto insert()
|
||||
-> blank_insert_t<void>
|
||||
inline auto insert() -> blank_insert_t<void>
|
||||
{
|
||||
return {blank_insert_t<void>()};
|
||||
}
|
||||
|
||||
template <typename Table>
|
||||
constexpr auto insert_into(Table table)
|
||||
-> decltype(blank_insert_t<void>().into(table))
|
||||
constexpr auto insert_into(Table table) -> decltype(blank_insert_t<void>().into(table))
|
||||
{
|
||||
return {blank_insert_t<void>().into(table)};
|
||||
}
|
||||
|
||||
template <typename Database>
|
||||
constexpr auto dynamic_insert(const Database&)
|
||||
-> decltype(blank_insert_t<Database>())
|
||||
constexpr auto dynamic_insert(const Database&) -> decltype(blank_insert_t<Database>())
|
||||
{
|
||||
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
|
||||
return {blank_insert_t<Database>()};
|
||||
}
|
||||
|
||||
template <typename Database, typename Table>
|
||||
constexpr auto dynamic_insert_into(const Database&, Table table)
|
||||
-> decltype(blank_insert_t<Database>().into(table))
|
||||
constexpr auto dynamic_insert_into(const Database&, Table table) -> decltype(blank_insert_t<Database>().into(table))
|
||||
{
|
||||
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
|
||||
return {blank_insert_t<Database>().into(table)};
|
||||
|
@ -65,29 +65,24 @@ namespace sqlpp
|
||||
using _wrapped_value_t = wrap_operand_t<_pure_value_t>;
|
||||
using _tvin_t = tvin_t<_wrapped_value_t>;
|
||||
|
||||
insert_value_t(rhs_wrap_t<_wrapped_value_t, _trivial_value_is_null> rhs):
|
||||
_is_null(rhs._is_null()),
|
||||
_is_default(rhs._is_default()),
|
||||
_value(rhs._expr._t)
|
||||
{}
|
||||
insert_value_t(rhs_wrap_t<_wrapped_value_t, _trivial_value_is_null> rhs)
|
||||
: _is_null(rhs._is_null()), _is_default(rhs._is_default()), _value(rhs._expr._t)
|
||||
{
|
||||
}
|
||||
|
||||
insert_value_t(rhs_wrap_t<_tvin_t, _trivial_value_is_null> rhs):
|
||||
_is_null(rhs._is_null()),
|
||||
_is_default(rhs._is_default()),
|
||||
_value(rhs._expr._value)
|
||||
{}
|
||||
insert_value_t(rhs_wrap_t<_tvin_t, _trivial_value_is_null> rhs)
|
||||
: _is_null(rhs._is_null()), _is_default(rhs._is_default()), _value(rhs._expr._value)
|
||||
{
|
||||
}
|
||||
|
||||
insert_value_t(const rhs_wrap_t<null_t, _trivial_value_is_null>&):
|
||||
_is_null(true),
|
||||
_is_default(false),
|
||||
_value{}
|
||||
{}
|
||||
insert_value_t(const rhs_wrap_t<null_t, _trivial_value_is_null>&) : _is_null(true), _is_default(false), _value{}
|
||||
{
|
||||
}
|
||||
|
||||
insert_value_t(const rhs_wrap_t<default_value_t, _trivial_value_is_null>&):
|
||||
_is_null(false),
|
||||
_is_default(true),
|
||||
_value{}
|
||||
{}
|
||||
insert_value_t(const rhs_wrap_t<default_value_t, _trivial_value_is_null>&)
|
||||
: _is_null(false), _is_default(true), _value{}
|
||||
{
|
||||
}
|
||||
|
||||
insert_value_t(const insert_value_t&) = default;
|
||||
insert_value_t(insert_value_t&&) = default;
|
||||
@ -108,8 +103,7 @@ namespace sqlpp
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
if ((trivial_value_is_null_t<typename T::_column_t>::value and t._value._is_trivial())
|
||||
or t._is_null)
|
||||
if ((trivial_value_is_null_t<typename T::_column_t>::value and t._value._is_trivial()) or t._is_null)
|
||||
{
|
||||
context << "NULL";
|
||||
}
|
||||
@ -120,7 +114,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -58,7 +58,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
struct insert_default_values_data_t
|
||||
{};
|
||||
{
|
||||
};
|
||||
|
||||
// COLUMN AND VALUE LIST
|
||||
struct insert_default_values_t
|
||||
@ -83,8 +84,14 @@ namespace sqlpp
|
||||
using _data_t = insert_default_values_data_t;
|
||||
|
||||
_impl_t<Policies> default_values;
|
||||
_impl_t<Policies>& operator()() { return default_values; }
|
||||
const _impl_t<Policies>& operator()() const { return default_values; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return default_values;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return default_values;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.default_values)
|
||||
@ -99,11 +106,10 @@ namespace sqlpp
|
||||
template <typename Database, typename... Assignments>
|
||||
struct insert_list_data_t
|
||||
{
|
||||
insert_list_data_t(Assignments... assignments):
|
||||
_assignments(assignments...),
|
||||
_columns({assignments._lhs}...),
|
||||
_values(assignments._rhs...)
|
||||
{}
|
||||
insert_list_data_t(Assignments... assignments)
|
||||
: _assignments(assignments...), _columns({assignments._lhs}...), _values(assignments._rhs...)
|
||||
{
|
||||
}
|
||||
|
||||
insert_list_data_t(const insert_list_data_t&) = default;
|
||||
insert_list_data_t(insert_list_data_t&&) = default;
|
||||
@ -111,7 +117,8 @@ namespace sqlpp
|
||||
insert_list_data_t& operator=(insert_list_data_t&&) = default;
|
||||
~insert_list_data_t() = default;
|
||||
|
||||
std::tuple<Assignments...> _assignments; // FIXME: Need to replace _columns and _values by _assignments (connector-container requires assignments)
|
||||
std::tuple<Assignments...> _assignments; // FIXME: Need to replace _columns and _values by _assignments
|
||||
// (connector-container requires assignments)
|
||||
std::tuple<simple_column_t<lhs_t<Assignments>>...> _columns;
|
||||
std::tuple<rhs_t<Assignments>...> _values;
|
||||
interpretable_list_t<Database> _dynamic_columns;
|
||||
@ -125,7 +132,8 @@ namespace sqlpp
|
||||
template <typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one insert assignment requires a table which is otherwise not known in the statement");
|
||||
static_assert(wrong_t<T>::value,
|
||||
"at least one insert assignment requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
@ -161,16 +169,15 @@ namespace sqlpp
|
||||
static_assert(_is_dynamic::value, "add must not be called for static from()");
|
||||
static_assert(is_assignment_t<Assignment>::value, "add() arguments require to be assigments");
|
||||
using _assigned_columns = detail::make_type_set_t<lhs_t<Assignments>...>;
|
||||
static_assert(not detail::is_element_of<lhs_t<Assignment>, _assigned_columns>::value, "Must not assign value to column twice");
|
||||
static_assert(not detail::is_element_of<lhs_t<Assignment>, _assigned_columns>::value,
|
||||
"Must not assign value to column twice");
|
||||
static_assert(not must_not_insert_t<lhs_t<Assignment>>::value, "add() argument must not be used in insert");
|
||||
static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables<Assignment>::value, "add() contains a column from a foreign table");
|
||||
static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables<Assignment>::value,
|
||||
"add() contains a column from a foreign table");
|
||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Assignment>;
|
||||
_serialize_check::_();
|
||||
|
||||
using ok = logic::all_t<
|
||||
_is_dynamic::value,
|
||||
is_assignment_t<Assignment>::value,
|
||||
_serialize_check::type::value>;
|
||||
using ok = logic::all_t<_is_dynamic::value, is_assignment_t<Assignment>::value, _serialize_check::type::value>;
|
||||
|
||||
_add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert
|
||||
}
|
||||
@ -185,6 +192,7 @@ namespace sqlpp
|
||||
|
||||
template <typename Assignment>
|
||||
void _add_impl(Assignment assignment, const std::false_type&);
|
||||
|
||||
public:
|
||||
_data_t _data;
|
||||
};
|
||||
@ -196,8 +204,14 @@ namespace sqlpp
|
||||
using _data_t = insert_list_data_t<Database, Assignments...>;
|
||||
|
||||
_impl_t<Policies> insert_list;
|
||||
_impl_t<Policies>& operator()() { return insert_list; }
|
||||
const _impl_t<Policies>& operator()() const { return insert_list; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return insert_list;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return insert_list;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.insert_list)
|
||||
@ -209,15 +223,14 @@ namespace sqlpp
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_insert_assignments_t>::type;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template <typename... Columns>
|
||||
struct column_list_data_t
|
||||
{
|
||||
column_list_data_t(Columns... cols):
|
||||
_columns(simple_column_t<Columns>{cols}...)
|
||||
{}
|
||||
column_list_data_t(Columns... cols) : _columns(simple_column_t<Columns>{cols}...)
|
||||
{
|
||||
}
|
||||
|
||||
column_list_data_t(const column_list_data_t&) = default;
|
||||
column_list_data_t(column_list_data_t&&) = default;
|
||||
@ -237,7 +250,8 @@ namespace sqlpp
|
||||
template <typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one column requires a table which is otherwise not known in the statement");
|
||||
static_assert(wrong_t<T>::value,
|
||||
"at least one column requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
@ -249,7 +263,6 @@ namespace sqlpp
|
||||
|
||||
using _value_tuple_t = typename column_list_data_t<Columns...>::_value_tuple_t;
|
||||
|
||||
|
||||
// Data
|
||||
using _data_t = column_list_data_t<Columns...>;
|
||||
|
||||
@ -260,14 +273,13 @@ namespace sqlpp
|
||||
template <typename... Assignments>
|
||||
void add(Assignments... assignments)
|
||||
{
|
||||
static_assert(logic::all_t<is_assignment_t<Assignments>::value...>::value, "add_values() arguments have to be assignments");
|
||||
static_assert(logic::all_t<is_assignment_t<Assignments>::value...>::value,
|
||||
"add_values() arguments have to be assignments");
|
||||
using _arg_value_tuple = std::tuple<insert_value_t<lhs_t<Assignments>>...>;
|
||||
using _args_correct = std::is_same<_arg_value_tuple, _value_tuple_t>;
|
||||
static_assert(_args_correct::value, "add_values() arguments do not match columns() arguments");
|
||||
|
||||
using ok = logic::all_t<
|
||||
logic::all_t<is_assignment_t<Assignments>::value...>::value,
|
||||
_args_correct::value>;
|
||||
using ok = logic::all_t<logic::all_t<is_assignment_t<Assignments>::value...>::value, _args_correct::value>;
|
||||
|
||||
_add_impl(ok(), assignments...); // dispatch to prevent compile messages after the static_assert
|
||||
}
|
||||
@ -281,6 +293,7 @@ namespace sqlpp
|
||||
|
||||
template <typename... Assignments>
|
||||
void _add_impl(const std::false_type&, Assignments... assignments);
|
||||
|
||||
public:
|
||||
_data_t _data;
|
||||
};
|
||||
@ -292,8 +305,14 @@ namespace sqlpp
|
||||
using _data_t = column_list_data_t<Columns...>;
|
||||
|
||||
_impl_t<Policies> values;
|
||||
_impl_t<Policies>& operator()() { return values; }
|
||||
const _impl_t<Policies>& operator()() const { return values; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return values;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return values;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.values)
|
||||
@ -341,8 +360,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_insert_values;
|
||||
_impl_t<Policies>& operator()() { return no_insert_values; }
|
||||
const _impl_t<Policies>& operator()() const { return no_insert_values; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_insert_values;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_insert_values;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_insert_values)
|
||||
@ -363,17 +388,16 @@ namespace sqlpp
|
||||
|
||||
using _consistency_check = assert_insert_values_t;
|
||||
|
||||
auto default_values() const
|
||||
-> _new_statement_t<std::true_type, insert_default_values_t>
|
||||
auto default_values() const -> _new_statement_t<std::true_type, insert_default_values_t>
|
||||
{
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), insert_default_values_data_t{}};
|
||||
}
|
||||
|
||||
template <typename... Columns>
|
||||
auto columns(Columns... cols) const
|
||||
-> _new_statement_t<_column_check<Columns...>, column_list_t<Columns...>>
|
||||
auto columns(Columns... cols) const -> _new_statement_t<_column_check<Columns...>, column_list_t<Columns...>>
|
||||
{
|
||||
static_assert(logic::all_t<is_column_t<Columns>::value...>::value, "at least one argument is not a column in columns()");
|
||||
static_assert(logic::all_t<is_column_t<Columns>::value...>::value,
|
||||
"at least one argument is not a column in columns()");
|
||||
static_assert(sizeof...(Columns), "at least one column required in columns()");
|
||||
|
||||
return _columns_impl(_column_check<Columns...>{}, cols...);
|
||||
@ -394,46 +418,55 @@ namespace sqlpp
|
||||
-> _new_statement_t<_assignment_check<Assignments...>, insert_list_t<_database_t, Assignments...>>
|
||||
{
|
||||
static_assert(_assignment_check<Assignments...>::value, "at least one argument is not an assignment in set()");
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_set must not be called in a static statement");
|
||||
static_assert(not std::is_same<_database_t, void>::value,
|
||||
"dynamic_set must not be called in a static statement");
|
||||
|
||||
return _set_impl<_database_t>(_assignment_check<Assignments...>{}, assignments...);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename... Columns>
|
||||
auto _columns_impl(const std::false_type&, Columns... cols) const
|
||||
-> bad_statement;
|
||||
auto _columns_impl(const std::false_type&, Columns... cols) const -> bad_statement;
|
||||
|
||||
template <typename... Columns>
|
||||
auto _columns_impl(const std::true_type&, Columns... cols) const
|
||||
-> _new_statement_t<std::true_type, column_list_t<Columns...>>
|
||||
{
|
||||
static_assert(not detail::has_duplicates<Columns...>::value, "at least one duplicate argument detected in columns()");
|
||||
static_assert(logic::none_t<must_not_insert_t<Columns>::value...>::value, "at least one column argument has a must_not_insert tag in its definition");
|
||||
static_assert(not detail::has_duplicates<Columns...>::value,
|
||||
"at least one duplicate argument detected in columns()");
|
||||
static_assert(logic::none_t<must_not_insert_t<Columns>::value...>::value,
|
||||
"at least one column argument has a must_not_insert tag in its definition");
|
||||
using _column_required_tables = detail::make_joined_set_t<required_tables_of<Columns>...>;
|
||||
static_assert(_column_required_tables::size::value == 1, "columns() contains columns from several tables");
|
||||
|
||||
static_assert(detail::have_all_required_columns<Columns...>::value, "At least one required column is missing in columns()");
|
||||
static_assert(detail::have_all_required_columns<Columns...>::value,
|
||||
"At least one required column is missing in columns()");
|
||||
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), column_list_data_t<Columns...>{cols...}};
|
||||
}
|
||||
|
||||
template <typename Database, typename... Assignments>
|
||||
auto _set_impl(const std::false_type&, Assignments... assignments) const
|
||||
-> bad_statement;
|
||||
auto _set_impl(const std::false_type&, Assignments... assignments) const -> bad_statement;
|
||||
|
||||
template <typename Database, typename... Assignments>
|
||||
auto _set_impl(const std::true_type&, Assignments... assignments) const
|
||||
-> _new_statement_t<std::true_type, insert_list_t<Database, Assignments...>>
|
||||
{
|
||||
static_assert(not detail::has_duplicates<lhs_t<Assignments>...>::value, "at least one duplicate column detected in set()");
|
||||
static_assert(logic::none_t<must_not_insert_t<lhs_t<Assignments>>::value...>::value, "at least one assignment is prohibited by its column definition in set()");
|
||||
static_assert(not detail::has_duplicates<lhs_t<Assignments>...>::value,
|
||||
"at least one duplicate column detected in set()");
|
||||
static_assert(logic::none_t<must_not_insert_t<lhs_t<Assignments>>::value...>::value,
|
||||
"at least one assignment is prohibited by its column definition in set()");
|
||||
|
||||
using _column_required_tables = detail::make_joined_set_t<required_tables_of<lhs_t<Assignments>>...>;
|
||||
static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true, "set() contains assignments for columns from several tables");
|
||||
static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true,
|
||||
"set() contains assignments for columns from several tables");
|
||||
|
||||
static_assert(not std::is_same<_database_t, void>::value or detail::have_all_required_columns<lhs_t<Assignments>...>::value, "At least one required column is missing in set()");
|
||||
static_assert(not std::is_same<_database_t, void>::value or
|
||||
detail::have_all_required_columns<lhs_t<Assignments>...>::value,
|
||||
"At least one required column is missing in set()");
|
||||
|
||||
return { static_cast<const derived_statement_t<Policies>&>(*this), insert_list_data_t<Database, Assignments...>{assignments...} };
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
||||
insert_list_data_t<Database, Assignments...>{assignments...}};
|
||||
}
|
||||
};
|
||||
};
|
||||
@ -509,7 +542,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -55,15 +55,13 @@ namespace sqlpp
|
||||
using _value_type = integral;
|
||||
using _cpp_value_type = typename _value_type::_cpp_value_type;
|
||||
|
||||
parameter_value_t():
|
||||
_value(0),
|
||||
_is_null(true)
|
||||
{}
|
||||
parameter_value_t() : _value(0), _is_null(true)
|
||||
{
|
||||
}
|
||||
|
||||
explicit parameter_value_t(const _cpp_value_type& val):
|
||||
_value(val),
|
||||
_is_null(false)
|
||||
{}
|
||||
explicit parameter_value_t(const _cpp_value_type& val) : _value(val), _is_null(false)
|
||||
{
|
||||
}
|
||||
|
||||
parameter_value_t& operator=(const _cpp_value_type& val)
|
||||
{
|
||||
@ -103,7 +101,10 @@ namespace sqlpp
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator _cpp_value_type() const { return _value; }
|
||||
operator _cpp_value_type() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target, size_t index) const
|
||||
@ -195,7 +196,6 @@ namespace sqlpp
|
||||
|
||||
return {*static_cast<const Base*>(this), {t}};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// integral column operators
|
||||
@ -244,16 +244,15 @@ namespace sqlpp
|
||||
|
||||
// integral result field
|
||||
template <typename Db, typename FieldSpec>
|
||||
struct result_field_t<integral, Db, FieldSpec>: public result_field_methods_t<result_field_t<integral, Db, FieldSpec>>
|
||||
struct result_field_t<integral, Db, FieldSpec>
|
||||
: public result_field_methods_t<result_field_t<integral, Db, FieldSpec>>
|
||||
{
|
||||
static_assert(std::is_same<value_type_of<FieldSpec>, integral>::value, "field type mismatch");
|
||||
using _cpp_value_type = typename integral::_cpp_value_type;
|
||||
|
||||
result_field_t():
|
||||
_is_valid(false),
|
||||
_is_null(true),
|
||||
_value(0)
|
||||
{}
|
||||
result_field_t() : _is_valid(false), _is_null(true), _value(0)
|
||||
{
|
||||
}
|
||||
|
||||
void _invalidate()
|
||||
{
|
||||
@ -324,6 +323,5 @@ namespace sqlpp
|
||||
using smallint = integral;
|
||||
using integer = integral;
|
||||
using bigint = integral;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -32,12 +32,10 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename T, typename Context>
|
||||
auto interpret(const T& t, Context& context)
|
||||
-> decltype(interpreter_t<Context, T>::_(t, context))
|
||||
auto interpret(const T& t, Context& context) -> decltype(interpreter_t<Context, T>::_(t, context))
|
||||
{
|
||||
return interpreter_t<Context, T>::_(t, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,8 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Element, typename Separator, typename Context, typename UseBraces>
|
||||
static void interpret_tuple_element(const Element& element, const Separator& separator, Context& context, const UseBraces&, size_t index)
|
||||
static void interpret_tuple_element(
|
||||
const Element& element, const Separator& separator, Context& context, const UseBraces&, size_t index)
|
||||
{
|
||||
if (index)
|
||||
context << separator;
|
||||
@ -46,32 +47,36 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template <typename Tuple, typename Separator, typename Context, typename UseBraces, size_t... Is>
|
||||
auto interpret_tuple_impl(const Tuple& t, const Separator& separator, Context& context, const UseBraces& useBraces, const detail::index_sequence<Is...>&)
|
||||
-> Context&
|
||||
auto interpret_tuple_impl(const Tuple& t,
|
||||
const Separator& separator,
|
||||
Context& context,
|
||||
const UseBraces& useBraces,
|
||||
const detail::index_sequence<Is...>&) -> Context &
|
||||
{
|
||||
// Note: A braced-init-list does guarantee the order of evaluation according to 12.6.1 [class.explicit.init] paragraph 2 and 8.5.4 [dcl.init.list] paragraph 4.
|
||||
// Note: A braced-init-list does guarantee the order of evaluation according to 12.6.1 [class.explicit.init]
|
||||
// paragraph 2 and 8.5.4 [dcl.init.list] paragraph 4.
|
||||
// See for example: "http://en.cppreference.com/w/cpp/utility/integer_sequence"
|
||||
// See also: "http://stackoverflow.com/questions/6245735/pretty-print-stdtuple/6245777#6245777"
|
||||
// Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could be used
|
||||
// Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could
|
||||
// be used
|
||||
using swallow = int[];
|
||||
(void) swallow{
|
||||
0, //workaround against -Wpedantic GCC warning "zero-size array 'int [0]'"
|
||||
(void)swallow{0, // workaround against -Wpedantic GCC warning "zero-size array 'int [0]'"
|
||||
(interpret_tuple_element(std::get<Is>(t), separator, context, useBraces, Is), 0)...};
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename Tuple, typename Separator, typename Context>
|
||||
auto interpret_tuple(const Tuple& t, const Separator& separator, Context& context)
|
||||
-> Context&
|
||||
auto interpret_tuple(const Tuple& t, const Separator& separator, Context& context) -> Context &
|
||||
{
|
||||
return interpret_tuple_impl(t, separator, context, std::true_type{}, detail::make_index_sequence<std::tuple_size<Tuple>::value>{});
|
||||
return interpret_tuple_impl(t, separator, context, std::true_type{},
|
||||
detail::make_index_sequence<std::tuple_size<Tuple>::value>{});
|
||||
}
|
||||
|
||||
template <typename Tuple, typename Separator, typename Context>
|
||||
auto interpret_tuple_without_braces(const Tuple& t, const Separator& separator, Context& context)
|
||||
-> Context&
|
||||
auto interpret_tuple_without_braces(const Tuple& t, const Separator& separator, Context& context) -> Context &
|
||||
{
|
||||
return interpret_tuple_impl(t, separator, context, std::false_type{}, detail::make_index_sequence<std::tuple_size<Tuple>::value>{});
|
||||
return interpret_tuple_impl(t, separator, context, std::false_type{},
|
||||
detail::make_index_sequence<std::tuple_size<Tuple>::value>{});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,10 +42,10 @@ namespace sqlpp
|
||||
using _interpreter_context_t = typename Db::_interpreter_context_t;
|
||||
|
||||
template <typename T>
|
||||
interpretable_t(T t):
|
||||
_requires_braces(requires_braces_t<T>::value),
|
||||
_impl(std::make_shared<_impl_t<T>>(t))
|
||||
{}
|
||||
interpretable_t(T t)
|
||||
: _requires_braces(requires_braces_t<T>::value), _impl(std::make_shared<_impl_t<T>>(t))
|
||||
{
|
||||
}
|
||||
|
||||
interpretable_t(const interpretable_t&) = default;
|
||||
interpretable_t(interpretable_t&&) = default;
|
||||
@ -60,9 +60,10 @@ namespace sqlpp
|
||||
|
||||
// This method only exists if Db::_serializer_context_t and serializer_context_t are not the same
|
||||
template <typename Context>
|
||||
auto serialize(Context& context) const
|
||||
-> typename std::enable_if<std::is_same<Context, _serializer_context_t>::value
|
||||
and not std::is_same<Context, serializer_context_t>::value, Context&>::type
|
||||
auto serialize(Context& context) const ->
|
||||
typename std::enable_if<std::is_same<Context, _serializer_context_t>::value and
|
||||
not std::is_same<Context, serializer_context_t>::value,
|
||||
Context&>::type
|
||||
{
|
||||
return _impl->db_serialize(context);
|
||||
}
|
||||
@ -86,9 +87,9 @@ namespace sqlpp
|
||||
struct _impl_t : public _impl_base
|
||||
{
|
||||
static_assert(not make_parameter_list_t<T>::size::value, "parameters not supported in dynamic statement parts");
|
||||
_impl_t(T t):
|
||||
_t(t)
|
||||
{}
|
||||
_impl_t(T t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
serializer_context_t& serialize(serializer_context_t& context) const
|
||||
{
|
||||
@ -134,7 +135,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -52,7 +52,6 @@ namespace sqlpp
|
||||
{
|
||||
_serializables.emplace_back(expr);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -67,7 +66,6 @@ namespace sqlpp
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename Context, typename List>
|
||||
@ -110,7 +108,6 @@ namespace sqlpp
|
||||
{
|
||||
return serializable_list_interpreter_t<Context, T>::_(t, separator, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -39,7 +39,6 @@ namespace sqlpp
|
||||
static_assert(wrong_t<interpreter_t>::value, "missing interpreter specialization");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,9 +41,9 @@ namespace sqlpp
|
||||
template <typename Database, typename Table>
|
||||
struct into_data_t
|
||||
{
|
||||
into_data_t(Table table):
|
||||
_table(table)
|
||||
{}
|
||||
into_data_t(Table table) : _table(table)
|
||||
{
|
||||
}
|
||||
|
||||
into_data_t(const into_data_t&) = default;
|
||||
into_data_t(into_data_t&&) = default;
|
||||
@ -63,7 +63,9 @@ namespace sqlpp
|
||||
|
||||
using _data_t = into_data_t<Database, Table>;
|
||||
|
||||
struct _alias_t {};
|
||||
struct _alias_t
|
||||
{
|
||||
};
|
||||
|
||||
// Member implementation with data and methods
|
||||
template <typename Policies>
|
||||
@ -79,8 +81,14 @@ namespace sqlpp
|
||||
using _data_t = into_data_t<Database, Table>;
|
||||
|
||||
_impl_t<Policies> into;
|
||||
_impl_t<Policies>& operator()() { return into; }
|
||||
const _impl_t<Policies>& operator()() const { return into; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return into;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return into;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.into)
|
||||
@ -90,7 +98,6 @@ namespace sqlpp
|
||||
|
||||
using _consistency_check = consistent_t;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
struct assert_into_t
|
||||
@ -127,8 +134,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_into;
|
||||
_impl_t<Policies>& operator()() { return no_into; }
|
||||
const _impl_t<Policies>& operator()() const { return no_into; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_into;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_into;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_into)
|
||||
@ -147,8 +160,7 @@ namespace sqlpp
|
||||
using _consistency_check = assert_into_t;
|
||||
|
||||
template <typename Table>
|
||||
auto into(Table table) const
|
||||
-> _new_statement_t<_check<Table>, into_t<void, Table>>
|
||||
auto into(Table table) const -> _new_statement_t<_check<Table>, into_t<void, Table>>
|
||||
{
|
||||
static_assert(_check<Table>::value, "argument is not a raw table in into()");
|
||||
return _into_impl<void>(_check<Table>{}, table);
|
||||
@ -156,14 +168,14 @@ namespace sqlpp
|
||||
|
||||
private:
|
||||
template <typename Database, typename Table>
|
||||
auto _into_impl(const std::false_type&, Table table) const
|
||||
-> bad_statement;
|
||||
auto _into_impl(const std::false_type&, Table table) const -> bad_statement;
|
||||
|
||||
template <typename Database, typename Table>
|
||||
auto _into_impl(const std::true_type&, Table table) const
|
||||
-> _new_statement_t<std::true_type, into_t<Database, Table>>
|
||||
{
|
||||
static_assert(required_tables_of<into_t<Database, Table>>::size::value == 0, "argument depends on another table in into()");
|
||||
static_assert(required_tables_of<into_t<Database, Table>>::size::value == 0,
|
||||
"argument depends on another table in into()");
|
||||
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), into_data_t<Database, Table>{table}};
|
||||
}
|
||||
|
@ -49,8 +49,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Operand>
|
||||
struct is_not_null_t:
|
||||
public expression_operators<is_not_null_t<Operand>, boolean>,
|
||||
struct is_not_null_t : public expression_operators<is_not_null_t<Operand>, boolean>,
|
||||
public alias_operators<is_not_null_t<Operand>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression, tag::is_selectable>;
|
||||
@ -58,9 +57,9 @@ namespace sqlpp
|
||||
|
||||
using _auto_alias_t = is_not_null_alias_t;
|
||||
|
||||
is_not_null_t(Operand operand):
|
||||
_operand(operand)
|
||||
{}
|
||||
is_not_null_t(Operand operand) : _operand(operand)
|
||||
{
|
||||
}
|
||||
|
||||
is_not_null_t(const is_not_null_t&) = default;
|
||||
is_not_null_t(is_not_null_t&&) = default;
|
||||
@ -84,7 +83,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -49,8 +49,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Operand>
|
||||
struct is_null_t:
|
||||
public expression_operators<is_null_t<Operand>, boolean>,
|
||||
struct is_null_t : public expression_operators<is_null_t<Operand>, boolean>,
|
||||
public alias_operators<is_null_t<Operand>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression, tag::is_selectable>;
|
||||
@ -58,9 +57,9 @@ namespace sqlpp
|
||||
|
||||
using _auto_alias_t = is_null_alias_t;
|
||||
|
||||
is_null_t(Operand operand):
|
||||
_operand(operand)
|
||||
{}
|
||||
is_null_t(Operand operand) : _operand(operand)
|
||||
{
|
||||
}
|
||||
|
||||
is_null_t(const is_null_t&) = default;
|
||||
is_null_t(is_null_t&&) = default;
|
||||
@ -84,7 +83,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -36,7 +36,8 @@ namespace sqlpp
|
||||
struct inner_join_t
|
||||
{
|
||||
template <typename Lhs, typename Rhs>
|
||||
using _provided_outer_tables = detail::make_joined_set_t<provided_outer_tables_of<Lhs>, provided_outer_tables_of<Rhs>>;
|
||||
using _provided_outer_tables =
|
||||
detail::make_joined_set_t<provided_outer_tables_of<Lhs>, provided_outer_tables_of<Rhs>>;
|
||||
|
||||
static constexpr const char* _name = " INNER ";
|
||||
};
|
||||
@ -74,7 +75,8 @@ namespace sqlpp
|
||||
static_assert(not is_join_t<Rhs>::value, "rhs argument for join must not be a join");
|
||||
static_assert(is_noop<On>::value or is_on_t<On>::value, "invalid on expression in join().on()");
|
||||
|
||||
static_assert(detail::is_disjunct_from<provided_tables_of<Lhs>, provided_tables_of<Rhs>>::value, "joined tables must not be identical");
|
||||
static_assert(detail::is_disjunct_from<provided_tables_of<Lhs>, provided_tables_of<Rhs>>::value,
|
||||
"joined tables must not be identical");
|
||||
|
||||
static_assert(required_tables_of<join_t>::size::value == 0, "joined tables must not depend on other tables");
|
||||
|
||||
@ -82,16 +84,13 @@ namespace sqlpp
|
||||
using set_on_t = join_t<JoinType, Lhs, Rhs, OnT>;
|
||||
|
||||
template <typename... Expr>
|
||||
auto on(Expr... expr)
|
||||
-> set_on_t<on_t<void, Expr...>>
|
||||
auto on(Expr... expr) -> set_on_t<on_t<void, Expr...>>
|
||||
{
|
||||
static_assert(is_noop<On>::value, "cannot call on() twice for a single join()");
|
||||
static_assert(logic::all_t<is_expression_t<Expr>::value...>::value, "at least one argument is not an expression in on()");
|
||||
static_assert(logic::all_t<is_expression_t<Expr>::value...>::value,
|
||||
"at least one argument is not an expression in on()");
|
||||
|
||||
return { _lhs,
|
||||
_rhs,
|
||||
{std::tuple<Expr...>{expr...}, {}}
|
||||
};
|
||||
return {_lhs, _rhs, {std::tuple<Expr...>{expr...}, {}}};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -151,7 +150,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -35,8 +35,7 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Operand, typename Pattern>
|
||||
struct like_t:
|
||||
public expression_operators<like_t<Operand, Pattern>, boolean>,
|
||||
struct like_t : public expression_operators<like_t<Operand, Pattern>, boolean>,
|
||||
public alias_operators<like_t<Operand, Pattern>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression, tag::is_selectable>;
|
||||
@ -50,15 +49,20 @@ namespace sqlpp
|
||||
struct _member_t
|
||||
{
|
||||
T like;
|
||||
T& operator()() { return like; }
|
||||
const T& operator()() const { return like; }
|
||||
T& operator()()
|
||||
{
|
||||
return like;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return like;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
like_t(Operand operand, Pattern pattern):
|
||||
_operand(operand),
|
||||
_pattern(pattern)
|
||||
{}
|
||||
like_t(Operand operand, Pattern pattern) : _operand(operand), _pattern(pattern)
|
||||
{
|
||||
}
|
||||
|
||||
like_t(const like_t&) = default;
|
||||
like_t(like_t&&) = default;
|
||||
|
@ -37,9 +37,9 @@ namespace sqlpp
|
||||
template <typename Limit>
|
||||
struct limit_data_t
|
||||
{
|
||||
limit_data_t(Limit value):
|
||||
_value(value)
|
||||
{}
|
||||
limit_data_t(Limit value) : _value(value)
|
||||
{
|
||||
}
|
||||
|
||||
limit_data_t(const limit_data_t&) = default;
|
||||
limit_data_t(limit_data_t&&) = default;
|
||||
@ -74,8 +74,14 @@ namespace sqlpp
|
||||
using _data_t = limit_data_t<Limit>;
|
||||
|
||||
_impl_t<Policies> limit;
|
||||
_impl_t<Policies>& operator()() { return limit; }
|
||||
const _impl_t<Policies>& operator()() const { return limit; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.limit)
|
||||
@ -91,15 +97,13 @@ namespace sqlpp
|
||||
template <typename Database>
|
||||
struct dynamic_limit_data_t
|
||||
{
|
||||
dynamic_limit_data_t():
|
||||
_value(noop())
|
||||
dynamic_limit_data_t() : _value(noop())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Limit>
|
||||
dynamic_limit_data_t(Limit value):
|
||||
_initialized(true),
|
||||
_value(wrap_operand_t<Limit>(value))
|
||||
dynamic_limit_data_t(Limit value)
|
||||
: _initialized(true), _value(wrap_operand_t<Limit>(value))
|
||||
{
|
||||
}
|
||||
|
||||
@ -136,6 +140,7 @@ namespace sqlpp
|
||||
_data._value = arg_t{value};
|
||||
_data._initialized = true;
|
||||
}
|
||||
|
||||
public:
|
||||
_data_t _data;
|
||||
};
|
||||
@ -147,8 +152,14 @@ namespace sqlpp
|
||||
using _data_t = dynamic_limit_data_t<Database>;
|
||||
|
||||
_impl_t<Policies> limit;
|
||||
_impl_t<Policies>& operator()() { return limit; }
|
||||
const _impl_t<Policies>& operator()() const { return limit; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.limit)
|
||||
@ -182,8 +193,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_limit;
|
||||
_impl_t<Policies>& operator()() { return no_limit; }
|
||||
const _impl_t<Policies>& operator()() const { return no_limit; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_limit;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_limit;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_limit)
|
||||
@ -202,31 +219,26 @@ namespace sqlpp
|
||||
using _consistency_check = consistent_t;
|
||||
|
||||
template <typename Arg>
|
||||
auto limit(Arg arg) const
|
||||
-> _new_statement_t<_check<Arg>, limit_t<wrap_operand_t<Arg>>>
|
||||
auto limit(Arg arg) const -> _new_statement_t<_check<Arg>, limit_t<wrap_operand_t<Arg>>>
|
||||
{
|
||||
static_assert(_check<Arg>::value, "limit requires an integral value or integral parameter");
|
||||
return _limit_impl(_check<Arg>{}, wrap_operand_t<Arg>{arg});
|
||||
}
|
||||
|
||||
auto dynamic_limit() const
|
||||
-> _new_statement_t<std::true_type, dynamic_limit_t<_database_t>>
|
||||
auto dynamic_limit() const -> _new_statement_t<std::true_type, dynamic_limit_t<_database_t>>
|
||||
{
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), dynamic_limit_data_t<_database_t>{}};
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Arg>
|
||||
auto _limit_impl(const std::false_type&, Arg arg) const
|
||||
-> bad_statement;
|
||||
auto _limit_impl(const std::false_type&, Arg arg) const -> bad_statement;
|
||||
|
||||
template <typename Arg>
|
||||
auto _limit_impl(const std::true_type&, Arg arg) const
|
||||
-> _new_statement_t<std::true_type, limit_t<Arg>>
|
||||
auto _limit_impl(const std::true_type&, Arg arg) const -> _new_statement_t<std::true_type, limit_t<Arg>>
|
||||
{
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), limit_data_t<Arg>{arg}};
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -39,19 +39,15 @@ namespace sqlpp
|
||||
|
||||
// see http://lists.boost.org/Archives/boost/2014/05/212946.php :-)
|
||||
template <bool... B>
|
||||
using all_t = std::integral_constant<
|
||||
bool,
|
||||
std::is_same<logic_helper<B...>, logic_helper<(true or B)...>>::value>;
|
||||
using all_t = std::integral_constant<bool, std::is_same<logic_helper<B...>, logic_helper<(true or B)...>>::value>;
|
||||
|
||||
template <bool... B>
|
||||
using any_t = std::integral_constant<
|
||||
bool,
|
||||
not std::is_same<logic_helper<B...>, logic_helper<(false and B)...>>::value>;
|
||||
using any_t =
|
||||
std::integral_constant<bool, not std::is_same<logic_helper<B...>, logic_helper<(false and B)...>>::value>;
|
||||
|
||||
template <bool... B>
|
||||
using none_t = std::integral_constant<
|
||||
bool,
|
||||
std::is_same<logic_helper<B...>, logic_helper<(false and B)...>>::value>;
|
||||
using none_t =
|
||||
std::integral_constant<bool, std::is_same<logic_helper<B...>, logic_helper<(false and B)...>>::value>;
|
||||
|
||||
template <bool>
|
||||
struct not_impl;
|
||||
@ -68,15 +64,12 @@ namespace sqlpp
|
||||
using type = std::true_type;
|
||||
};
|
||||
|
||||
|
||||
template <template <typename> class Predicate, typename... T>
|
||||
using not_t = typename not_impl<Predicate<T>::value...>::type;
|
||||
|
||||
|
||||
template <typename T>
|
||||
using identity_t = T;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -42,25 +42,29 @@ namespace sqlpp
|
||||
struct _member_t
|
||||
{
|
||||
T max;
|
||||
T& operator()() { return max; }
|
||||
const T& operator()() const { return max; }
|
||||
T& operator()()
|
||||
{
|
||||
return max;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return max;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Expr>
|
||||
struct max_t:
|
||||
public expression_operators<max_t<Expr>, value_type_of<Expr>>,
|
||||
public alias_operators<max_t<Expr>>
|
||||
struct max_t : public expression_operators<max_t<Expr>, value_type_of<Expr>>, public alias_operators<max_t<Expr>>
|
||||
{
|
||||
using _traits = make_traits<value_type_of<Expr>, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
|
||||
using _auto_alias_t = max_alias_t;
|
||||
|
||||
max_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
max_t(Expr expr) : _expr(expr)
|
||||
{
|
||||
}
|
||||
|
||||
max_t(const max_t&) = default;
|
||||
max_t(max_t&&) = default;
|
||||
@ -89,11 +93,11 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
auto max(T t) -> max_t<wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "max() cannot be used on an aggregate function");
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
|
||||
"max() cannot be used on an aggregate function");
|
||||
static_assert(is_expression_t<wrap_operand_t<T>>::value, "max() requires an expression as argument");
|
||||
return {t};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -42,25 +42,29 @@ namespace sqlpp
|
||||
struct _member_t
|
||||
{
|
||||
T min;
|
||||
T& operator()() { return min; }
|
||||
const T& operator()() const { return min; }
|
||||
T& operator()()
|
||||
{
|
||||
return min;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return min;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Expr>
|
||||
struct min_t:
|
||||
public expression_operators<min_t<Expr>, value_type_of<Expr>>,
|
||||
public alias_operators<min_t<Expr>>
|
||||
struct min_t : public expression_operators<min_t<Expr>, value_type_of<Expr>>, public alias_operators<min_t<Expr>>
|
||||
{
|
||||
using _traits = make_traits<value_type_of<Expr>, tag::is_expression, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Expr, aggregate_function>;
|
||||
|
||||
using _auto_alias_t = min_alias_t;
|
||||
|
||||
min_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
min_t(Expr expr) : _expr(expr)
|
||||
{
|
||||
}
|
||||
|
||||
min_t(const min_t&) = default;
|
||||
min_t(min_t&&) = default;
|
||||
@ -89,11 +93,11 @@ namespace sqlpp
|
||||
template <typename T>
|
||||
auto min(T t) -> min_t<wrap_operand_t<T>>
|
||||
{
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "min() cannot be used on an aggregate function");
|
||||
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value,
|
||||
"min() cannot be used on an aggregate function");
|
||||
static_assert(is_expression_t<wrap_operand_t<T>>::value, "min() requires an expression as argument");
|
||||
return {t};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -44,15 +44,16 @@ namespace sqlpp
|
||||
using _traits = make_traits<no_value_t>;
|
||||
using _nodes = detail::type_vector<Columns...>;
|
||||
|
||||
static_assert(logic::all_t<is_selectable_t<Columns>::value...>::value, "multi_column parameters need to be named expressions");
|
||||
static_assert(logic::all_t<is_selectable_t<Columns>::value...>::value,
|
||||
"multi_column parameters need to be named expressions");
|
||||
|
||||
multi_column_t(std::tuple<Columns...> columns):
|
||||
_columns(columns)
|
||||
{}
|
||||
multi_column_t(std::tuple<Columns...> columns) : _columns(columns)
|
||||
{
|
||||
}
|
||||
|
||||
multi_column_t(Columns... columns):
|
||||
_columns(columns...)
|
||||
{}
|
||||
multi_column_t(Columns... columns) : _columns(columns...)
|
||||
{
|
||||
}
|
||||
|
||||
multi_column_t(const multi_column_t&) = default;
|
||||
multi_column_t(multi_column_t&&) = default;
|
||||
@ -75,21 +76,22 @@ namespace sqlpp
|
||||
using _traits = make_traits<no_value_t, tag::is_alias, tag::is_multi_column, tag::is_selectable>;
|
||||
using _nodes = detail::type_vector<Columns...>;
|
||||
|
||||
static_assert(logic::all_t<is_selectable_t<Columns>::value...>::value, "multi_column parameters need to be named expressions");
|
||||
static_assert(logic::all_t<is_selectable_t<Columns>::value...>::value,
|
||||
"multi_column parameters need to be named expressions");
|
||||
|
||||
using _alias_t = typename AliasProvider::_alias_t;
|
||||
|
||||
multi_column_alias_t(multi_column_t<void, Columns...> multi_column):
|
||||
_columns(multi_column._columns)
|
||||
{}
|
||||
multi_column_alias_t(multi_column_t<void, Columns...> multi_column) : _columns(multi_column._columns)
|
||||
{
|
||||
}
|
||||
|
||||
multi_column_alias_t(std::tuple<Columns...> columns):
|
||||
_columns(columns)
|
||||
{}
|
||||
multi_column_alias_t(std::tuple<Columns...> columns) : _columns(columns)
|
||||
{
|
||||
}
|
||||
|
||||
multi_column_alias_t(Columns... columns):
|
||||
_columns(columns...)
|
||||
{}
|
||||
multi_column_alias_t(Columns... columns) : _columns(columns...)
|
||||
{
|
||||
}
|
||||
|
||||
multi_column_alias_t(const multi_column_alias_t&) = default;
|
||||
multi_column_alias_t(multi_column_alias_t&&) = default;
|
||||
@ -129,18 +131,14 @@ namespace sqlpp
|
||||
{
|
||||
template <typename... Columns>
|
||||
using make_multi_column_t =
|
||||
copy_tuple_args_t<multi_column_t, void,
|
||||
decltype(column_tuple_merge(std::declval<Columns>()...))>;
|
||||
copy_tuple_args_t<multi_column_t, void, decltype(column_tuple_merge(std::declval<Columns>()...))>;
|
||||
}
|
||||
|
||||
template <typename... Columns>
|
||||
auto multi_column(Columns... columns)
|
||||
-> detail::make_multi_column_t<Columns...>
|
||||
auto multi_column(Columns... columns) -> detail::make_multi_column_t<Columns...>
|
||||
{
|
||||
return detail::make_multi_column_t<Columns...>(std::tuple_cat(detail::as_column_tuple<Columns>::_(columns)...));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,10 +41,10 @@ namespace sqlpp
|
||||
using _interpreter_context_t = typename Db::_interpreter_context_t;
|
||||
|
||||
template <typename T>
|
||||
named_interpretable_t(T t):
|
||||
_requires_braces(requires_braces_t<T>::value),
|
||||
_impl(std::make_shared<_impl_t<T>>(t))
|
||||
{}
|
||||
named_interpretable_t(T t)
|
||||
: _requires_braces(requires_braces_t<T>::value), _impl(std::make_shared<_impl_t<T>>(t))
|
||||
{
|
||||
}
|
||||
|
||||
named_interpretable_t(const named_interpretable_t&) = default;
|
||||
named_interpretable_t(named_interpretable_t&&) = default;
|
||||
@ -59,9 +59,10 @@ namespace sqlpp
|
||||
|
||||
// This method only exists if Db::_serializer_context_t and serializer_context_t are not the same
|
||||
template <typename Context>
|
||||
auto serialize(Context& context) const
|
||||
-> typename std::enable_if<std::is_same<Context, _serializer_context_t>::value
|
||||
and not std::is_same<Context, serializer_context_t>::value, Context&>::type
|
||||
auto serialize(Context& context) const ->
|
||||
typename std::enable_if<std::is_same<Context, _serializer_context_t>::value and
|
||||
not std::is_same<Context, serializer_context_t>::value,
|
||||
Context&>::type
|
||||
{
|
||||
return _impl->db_serialize(context);
|
||||
}
|
||||
@ -91,9 +92,9 @@ namespace sqlpp
|
||||
struct _impl_t : public _impl_base
|
||||
{
|
||||
static_assert(not make_parameter_list_t<T>::size::value, "parameters not supported in dynamic statement parts");
|
||||
_impl_t(T t):
|
||||
_t(t)
|
||||
{}
|
||||
_impl_t(T t) : _t(t)
|
||||
{
|
||||
}
|
||||
|
||||
serializer_context_t& serialize(serializer_context_t& context) const
|
||||
{
|
||||
@ -144,7 +145,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -32,7 +32,9 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct no_data_t {};
|
||||
struct no_data_t
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, no_data_t>
|
||||
|
@ -46,6 +46,5 @@ namespace sqlpp
|
||||
struct column_operators<Base, no_value_t>
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -39,7 +39,9 @@ namespace sqlpp
|
||||
using _traits = make_traits<no_value_t, tag::is_noop>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
|
||||
struct _alias_t {};
|
||||
struct _alias_t
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Statement>
|
||||
struct _result_methods_t
|
||||
@ -66,15 +68,13 @@ namespace sqlpp
|
||||
|
||||
// Prepare
|
||||
template <typename Db, typename Composite>
|
||||
auto _prepare(Db& db, const Composite& composite) const
|
||||
-> prepared_execute_t<Db, Composite>
|
||||
auto _prepare(Db& db, const Composite& composite) const -> prepared_execute_t<Db, Composite>
|
||||
{
|
||||
return {{}, db.prepare_execute(composite)};
|
||||
}
|
||||
|
||||
template <typename Db>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_execute_t<Db, _statement_t>
|
||||
auto _prepare(Db& db) const -> prepared_execute_t<Db, _statement_t>
|
||||
{
|
||||
return {{}, db.prepare_execute(_get_statement())};
|
||||
}
|
||||
@ -94,7 +94,8 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_noop: std::is_same<T, noop> {};
|
||||
|
||||
struct is_noop : std::is_same<T, noop>
|
||||
{
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -50,8 +50,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Operand, typename... Args>
|
||||
struct not_in_t:
|
||||
public expression_operators<not_in_t<Operand, Args...>, boolean>,
|
||||
struct not_in_t : public expression_operators<not_in_t<Operand, Args...>, boolean>,
|
||||
public alias_operators<not_in_t<Operand, Args...>>
|
||||
{
|
||||
using _traits = make_traits<boolean, tag::is_expression, tag::is_selectable>;
|
||||
@ -61,10 +60,9 @@ namespace sqlpp
|
||||
|
||||
using _auto_alias_t = not_in_alias_t;
|
||||
|
||||
not_in_t(Operand operand, Args... args):
|
||||
_operand(operand),
|
||||
_args(args...)
|
||||
{}
|
||||
not_in_t(Operand operand, Args... args) : _operand(operand), _args(args...)
|
||||
{
|
||||
}
|
||||
|
||||
not_in_t(const not_in_t&) = default;
|
||||
not_in_t(not_in_t&&) = default;
|
||||
@ -121,8 +119,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -51,7 +51,6 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
constexpr null_t null = {};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -37,9 +37,9 @@ namespace sqlpp
|
||||
template <typename Offset>
|
||||
struct offset_data_t
|
||||
{
|
||||
offset_data_t(Offset value):
|
||||
_value(value)
|
||||
{}
|
||||
offset_data_t(Offset value) : _value(value)
|
||||
{
|
||||
}
|
||||
|
||||
offset_data_t(const offset_data_t&) = default;
|
||||
offset_data_t(offset_data_t&&) = default;
|
||||
@ -76,8 +76,14 @@ namespace sqlpp
|
||||
using _data_t = offset_data_t<Offset>;
|
||||
|
||||
_impl_t<Policies> offset;
|
||||
_impl_t<Policies>& operator()() { return offset; }
|
||||
const _impl_t<Policies>& operator()() const { return offset; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.offset)
|
||||
@ -93,15 +99,13 @@ namespace sqlpp
|
||||
template <typename Database>
|
||||
struct dynamic_offset_data_t
|
||||
{
|
||||
dynamic_offset_data_t():
|
||||
_value(noop())
|
||||
dynamic_offset_data_t() : _value(noop())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Offset>
|
||||
dynamic_offset_data_t(Offset value):
|
||||
_initialized(true),
|
||||
_value(wrap_operand_t<Offset>(value))
|
||||
dynamic_offset_data_t(Offset value)
|
||||
: _initialized(true), _value(wrap_operand_t<Offset>(value))
|
||||
{
|
||||
}
|
||||
|
||||
@ -138,6 +142,7 @@ namespace sqlpp
|
||||
_data._value = arg_t{value};
|
||||
_data._initialized = true;
|
||||
}
|
||||
|
||||
public:
|
||||
_data_t _data;
|
||||
};
|
||||
@ -149,8 +154,14 @@ namespace sqlpp
|
||||
using _data_t = dynamic_offset_data_t<Database>;
|
||||
|
||||
_impl_t<Policies> offset;
|
||||
_impl_t<Policies>& operator()() { return offset; }
|
||||
const _impl_t<Policies>& operator()() const { return offset; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.offset)
|
||||
@ -196,8 +207,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_offset;
|
||||
_impl_t<Policies>& operator()() { return no_offset; }
|
||||
const _impl_t<Policies>& operator()() const { return no_offset; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_offset;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_offset;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_offset)
|
||||
@ -216,32 +233,28 @@ namespace sqlpp
|
||||
using _consistency_check = consistent_t;
|
||||
|
||||
template <typename Arg>
|
||||
auto offset(Arg arg) const
|
||||
-> _new_statement_t<_check<Arg>, offset_t<wrap_operand_t<Arg>>>
|
||||
auto offset(Arg arg) const -> _new_statement_t<_check<Arg>, offset_t<wrap_operand_t<Arg>>>
|
||||
{
|
||||
static_assert(_check<Arg>::value, "offset requires an integral value or integral parameter");
|
||||
return _offset_impl(_check<Arg>{}, wrap_operand_t<Arg>{arg});
|
||||
}
|
||||
|
||||
auto dynamic_offset() const
|
||||
-> _new_statement_t<std::true_type, dynamic_offset_t<_database_t>>
|
||||
auto dynamic_offset() const -> _new_statement_t<std::true_type, dynamic_offset_t<_database_t>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_offset must not be called in a static statement");
|
||||
static_assert(not std::is_same<_database_t, void>::value,
|
||||
"dynamic_offset must not be called in a static statement");
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), dynamic_offset_data_t<_database_t>{}};
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Arg>
|
||||
auto _offset_impl(const std::false_type&, Arg arg) const
|
||||
-> bad_statement;
|
||||
auto _offset_impl(const std::false_type&, Arg arg) const -> bad_statement;
|
||||
|
||||
template <typename Arg>
|
||||
auto _offset_impl(const std::true_type&, Arg arg) const
|
||||
-> _new_statement_t<std::true_type, offset_t<Arg>>
|
||||
auto _offset_impl(const std::true_type&, Arg arg) const -> _new_statement_t<std::true_type, offset_t<Arg>>
|
||||
{
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this), offset_data_t<Arg>{arg}};
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -90,7 +90,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,9 +41,9 @@ namespace sqlpp
|
||||
template <typename Database, typename... Expressions>
|
||||
struct order_by_data_t
|
||||
{
|
||||
order_by_data_t(Expressions... expressions):
|
||||
_expressions(expressions...)
|
||||
{}
|
||||
order_by_data_t(Expressions... expressions) : _expressions(expressions...)
|
||||
{
|
||||
}
|
||||
|
||||
order_by_data_t(const order_by_data_t&) = default;
|
||||
order_by_data_t(order_by_data_t&&) = default;
|
||||
@ -62,7 +62,8 @@ namespace sqlpp
|
||||
template <typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one order-by expression requires a table which is otherwise not known in the statement");
|
||||
static_assert(wrong_t<T>::value,
|
||||
"at least one order-by expression requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,7 +94,8 @@ namespace sqlpp
|
||||
{
|
||||
static_assert(_is_dynamic::value, "add() must not be called for static order_by");
|
||||
static_assert(is_sort_order_t<Expression>::value, "invalid expression argument in order_by::add()");
|
||||
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value, "expression uses tables unknown to this statement in order_by::add()");
|
||||
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Expression>::value,
|
||||
"expression uses tables unknown to this statement in order_by::add()");
|
||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expression>;
|
||||
_serialize_check::_();
|
||||
|
||||
@ -111,6 +113,7 @@ namespace sqlpp
|
||||
|
||||
template <typename Expression>
|
||||
void _add_impl(Expression expression, const std::false_type&);
|
||||
|
||||
public:
|
||||
_data_t _data;
|
||||
};
|
||||
@ -122,8 +125,14 @@ namespace sqlpp
|
||||
using _data_t = order_by_data_t<Database, Expressions...>;
|
||||
|
||||
_impl_t<Policies> order_by;
|
||||
_impl_t<Policies>& operator()() { return order_by; }
|
||||
const _impl_t<Policies>& operator()() const { return order_by; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return order_by;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return order_by;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.order_by)
|
||||
@ -160,8 +169,14 @@ namespace sqlpp
|
||||
using _data_t = no_data_t;
|
||||
|
||||
_impl_t<Policies> no_order_by;
|
||||
_impl_t<Policies>& operator()() { return no_order_by; }
|
||||
const _impl_t<Policies>& operator()() const { return no_order_by; }
|
||||
_impl_t<Policies>& operator()()
|
||||
{
|
||||
return no_order_by;
|
||||
}
|
||||
const _impl_t<Policies>& operator()() const
|
||||
{
|
||||
return no_order_by;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto _get_member(T t) -> decltype(t.no_order_by)
|
||||
@ -193,7 +208,8 @@ namespace sqlpp
|
||||
auto dynamic_order_by(Expressions... expressions) const
|
||||
-> _new_statement_t<_check<Expressions...>, order_by_t<_database_t, Expressions...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_order_by must not be called in a static statement");
|
||||
static_assert(not std::is_same<_database_t, void>::value,
|
||||
"dynamic_order_by must not be called in a static statement");
|
||||
static_assert(_check<Expressions...>::value, "at least one argument is not a sort order in order_by()");
|
||||
|
||||
return _order_by_impl<_database_t>(_check<Expressions...>{}, expressions...);
|
||||
@ -201,16 +217,17 @@ namespace sqlpp
|
||||
|
||||
private:
|
||||
template <typename Database, typename... Expressions>
|
||||
auto _order_by_impl(const std::false_type&, Expressions... expressions) const
|
||||
-> bad_statement;
|
||||
auto _order_by_impl(const std::false_type&, Expressions... expressions) const -> bad_statement;
|
||||
|
||||
template <typename Database, typename... Expressions>
|
||||
auto _order_by_impl(const std::true_type&, Expressions... expressions) const
|
||||
-> _new_statement_t<std::true_type, order_by_t<_database_t, Expressions...>>
|
||||
{
|
||||
static_assert(not detail::has_duplicates<Expressions...>::value, "at least one duplicate argument detected in order_by()");
|
||||
static_assert(not detail::has_duplicates<Expressions...>::value,
|
||||
"at least one duplicate argument detected in order_by()");
|
||||
|
||||
return { static_cast<const derived_statement_t<Policies>&>(*this), order_by_data_t<Database, Expressions...>{expressions...} };
|
||||
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
||||
order_by_data_t<Database, Expressions...>{expressions...}};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -34,8 +34,7 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename ValueType, typename NameType>
|
||||
struct parameter_t:
|
||||
public expression_operators<parameter_t<ValueType, NameType>, ValueType>
|
||||
struct parameter_t : public expression_operators<parameter_t<ValueType, NameType>, ValueType>
|
||||
{
|
||||
using _traits = make_traits<ValueType, tag::is_parameter, tag::is_expression>;
|
||||
|
||||
@ -46,7 +45,8 @@ namespace sqlpp
|
||||
using _instance_t = member_t<NameType, parameter_value_t<ValueType>>;
|
||||
|
||||
parameter_t()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
parameter_t(const parameter_t&) = default;
|
||||
parameter_t(parameter_t&&) = default;
|
||||
@ -69,22 +69,19 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename NamedExpr>
|
||||
auto parameter(const NamedExpr&)
|
||||
-> parameter_t<value_type_of<NamedExpr>, NamedExpr>
|
||||
auto parameter(const NamedExpr&) -> parameter_t<value_type_of<NamedExpr>, NamedExpr>
|
||||
{
|
||||
static_assert(is_selectable_t<NamedExpr>::value, "not a named expression");
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename ValueType, typename AliasProvider>
|
||||
auto parameter(const ValueType&, const AliasProvider&)
|
||||
-> parameter_t<wrap_operand_t<ValueType>, AliasProvider>
|
||||
auto parameter(const ValueType&, const AliasProvider&) -> parameter_t<wrap_operand_t<ValueType>, AliasProvider>
|
||||
{
|
||||
static_assert(is_value_type_t<ValueType>::value, "first argument is not a value type");
|
||||
static_assert(is_alias_provider_t<AliasProvider>::value, "second argument is not an alias provider");
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -47,7 +47,8 @@ namespace sqlpp
|
||||
using size = std::integral_constant<std::size_t, sizeof...(Parameter)>;
|
||||
|
||||
parameter_list_t()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Target>
|
||||
void _bind(Target& target) const
|
||||
@ -60,13 +61,13 @@ namespace sqlpp
|
||||
void _bind_impl(Target& target, const detail::index_sequence<Is...>&) const
|
||||
{
|
||||
using swallow = int[]; // see interpret_tuple.h
|
||||
(void) swallow{(static_cast<typename std::tuple_element<Is, const _member_tuple_t>::type&>(*this)()._bind(target, Is), 0)...};
|
||||
(void)swallow{(
|
||||
static_cast<typename std::tuple_element<Is, const _member_tuple_t>::type&>(*this)()._bind(target, Is), 0)...};
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Exp>
|
||||
using make_parameter_list_t = parameter_list_t<parameters_of<Exp>>;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -68,7 +68,6 @@ namespace sqlpp
|
||||
|
||||
template <bool Check, typename Policies, typename Needle, typename Replacement>
|
||||
using new_statement_t = typename new_statement_impl<Check, Policies, Needle, Replacement>::type;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -78,54 +78,49 @@
|
||||
/***************************************************************************/
|
||||
// tools
|
||||
|
||||
#define SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) \
|
||||
BOOST_PP_TUPLE_ELEM(0, BOOST_PP_EXPAND table)
|
||||
#define SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) BOOST_PP_TUPLE_ELEM(0, BOOST_PP_EXPAND table)
|
||||
|
||||
#define SQLPP_DECLARE_TABLE_GET_TABLE_PROPS(table) \
|
||||
SQLPP_BOOST_PP_TUPLE_POP_FRONT(BOOST_PP_EXPAND table)
|
||||
#define SQLPP_DECLARE_TABLE_GET_TABLE_PROPS(table) SQLPP_BOOST_PP_TUPLE_POP_FRONT(BOOST_PP_EXPAND table)
|
||||
|
||||
#define SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(col) \
|
||||
BOOST_PP_TUPLE_ELEM(0, col)
|
||||
#define SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(col) BOOST_PP_TUPLE_ELEM(0, col)
|
||||
|
||||
#define SQLPP_DECLARE_TABLE_ENUM_COLUMNS(unused, table, elem) \
|
||||
,table::SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem)
|
||||
#define SQLPP_DECLARE_TABLE_ENUM_COLUMNS(unused, table, elem) , table::SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem)
|
||||
|
||||
/***************************************************************************/
|
||||
// columns
|
||||
|
||||
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_AUX(unused, size, idx, elem) \
|
||||
BOOST_PP_CAT( \
|
||||
SQLPP_DECLARE_COLUMN_GEN_TRAITS_ \
|
||||
,BOOST_PP_CAT(SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_, elem) \
|
||||
)(elem) \
|
||||
BOOST_PP_CAT(SQLPP_DECLARE_COLUMN_GEN_TRAITS_, BOOST_PP_CAT(SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_, elem))(elem) \
|
||||
BOOST_PP_COMMA_IF(BOOST_PP_LESS(BOOST_PP_ADD(idx, 1), size))
|
||||
|
||||
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS(props) \
|
||||
BOOST_PP_SEQ_FOR_EACH_I( \
|
||||
SQLPP_DECLARE_COLUMN_GEN_TRAITS_AUX \
|
||||
,BOOST_PP_TUPLE_SIZE(props) \
|
||||
,BOOST_PP_TUPLE_TO_SEQ(props) \
|
||||
)
|
||||
BOOST_PP_SEQ_FOR_EACH_I(SQLPP_DECLARE_COLUMN_GEN_TRAITS_AUX, BOOST_PP_TUPLE_SIZE(props), BOOST_PP_TUPLE_TO_SEQ(props))
|
||||
|
||||
#define SQLPP_DECLARE_COLUMN(unused, data, elem) \
|
||||
struct SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem) { \
|
||||
struct _alias_t { \
|
||||
static constexpr const char _literal[] = \
|
||||
BOOST_PP_STRINGIZE(SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem)); \
|
||||
struct SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem) \
|
||||
{ \
|
||||
struct _alias_t \
|
||||
{ \
|
||||
static constexpr const char _literal[] = BOOST_PP_STRINGIZE(SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem)); \
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>; \
|
||||
\
|
||||
template <typename T> \
|
||||
struct _member_t { \
|
||||
struct _member_t \
|
||||
{ \
|
||||
T SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); \
|
||||
\
|
||||
T& operator()() { return SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); } \
|
||||
const T& operator()() const { return SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); } \
|
||||
T& operator()() \
|
||||
{ \
|
||||
return SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); \
|
||||
} \
|
||||
const T& operator()() const \
|
||||
{ \
|
||||
return SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); \
|
||||
} \
|
||||
}; /* struct _member_t */ \
|
||||
}; /* struct _alias_t */ \
|
||||
\
|
||||
using _traits = sqlpp::make_traits< \
|
||||
SQLPP_DECLARE_COLUMN_GEN_TRAITS(SQLPP_BOOST_PP_TUPLE_POP_FRONT(elem)) \
|
||||
>; \
|
||||
using _traits = sqlpp::make_traits<SQLPP_DECLARE_COLUMN_GEN_TRAITS(SQLPP_BOOST_PP_TUPLE_POP_FRONT(elem))>; \
|
||||
\
|
||||
}; /* struct SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem) */
|
||||
|
||||
@ -133,74 +128,61 @@
|
||||
// table props
|
||||
|
||||
#define SQLPP_DECLARE_TABLE_GEN_PROPS_AUX(unused1, unused2, elem) \
|
||||
BOOST_PP_CAT( \
|
||||
SQLPP_DECLARE_TABLE_GEN_ \
|
||||
,BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_PROC_LAZY_, elem) \
|
||||
)(elem)
|
||||
BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GEN_, BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_PROC_LAZY_, elem))(elem)
|
||||
|
||||
#define SQLPP_DECLARE_TABLE_GEN_PROPS(table) \
|
||||
BOOST_PP_SEQ_FOR_EACH( \
|
||||
SQLPP_DECLARE_TABLE_GEN_PROPS_AUX \
|
||||
,~ \
|
||||
,BOOST_PP_TUPLE_TO_SEQ(SQLPP_BOOST_PP_TUPLE_POP_FRONT(table)) \
|
||||
)
|
||||
BOOST_PP_SEQ_FOR_EACH(SQLPP_DECLARE_TABLE_GEN_PROPS_AUX, ~, \
|
||||
BOOST_PP_TUPLE_TO_SEQ(SQLPP_BOOST_PP_TUPLE_POP_FRONT(table)))
|
||||
|
||||
/***************************************************************************/
|
||||
// main
|
||||
|
||||
#define SQLPP_DECLARE_TABLE_IMPL(table, cols) \
|
||||
namespace SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) { \
|
||||
namespace BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _) { \
|
||||
BOOST_PP_SEQ_FOR_EACH( \
|
||||
SQLPP_DECLARE_COLUMN \
|
||||
,~ \
|
||||
,cols \
|
||||
) \
|
||||
namespace SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) \
|
||||
{ \
|
||||
namespace BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _) \
|
||||
{ \
|
||||
BOOST_PP_SEQ_FOR_EACH(SQLPP_DECLARE_COLUMN, ~, cols) \
|
||||
} /* namespace BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _) */ \
|
||||
\
|
||||
struct SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) \
|
||||
: sqlpp::table_t< \
|
||||
SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) \
|
||||
BOOST_PP_SEQ_FOR_EACH( \
|
||||
SQLPP_DECLARE_TABLE_ENUM_COLUMNS \
|
||||
,BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _) \
|
||||
,cols \
|
||||
) \
|
||||
> \
|
||||
: sqlpp::table_t<SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) BOOST_PP_SEQ_FOR_EACH( \
|
||||
SQLPP_DECLARE_TABLE_ENUM_COLUMNS, BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _), cols)> \
|
||||
{ \
|
||||
BOOST_PP_IF( \
|
||||
BOOST_PP_LESS(BOOST_PP_TUPLE_SIZE(table), 2) \
|
||||
,BOOST_PP_TUPLE_EAT() \
|
||||
,SQLPP_DECLARE_TABLE_GEN_PROPS \
|
||||
)(BOOST_PP_EXPAND table) \
|
||||
BOOST_PP_IF(BOOST_PP_LESS(BOOST_PP_TUPLE_SIZE(table), 2), \
|
||||
BOOST_PP_TUPLE_EAT(), \
|
||||
SQLPP_DECLARE_TABLE_GEN_PROPS)(BOOST_PP_EXPAND table) \
|
||||
\
|
||||
struct _alias_t { \
|
||||
static constexpr const char _literal[] = \
|
||||
BOOST_PP_STRINGIZE(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table)); \
|
||||
struct _alias_t \
|
||||
{ \
|
||||
static constexpr const char _literal[] = BOOST_PP_STRINGIZE(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table)); \
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>; \
|
||||
\
|
||||
template <typename T> \
|
||||
struct _member_t { \
|
||||
struct _member_t \
|
||||
{ \
|
||||
T SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); \
|
||||
\
|
||||
T& operator()() { return SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); } \
|
||||
const T& operator()() const { return SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); } \
|
||||
T& operator()() \
|
||||
{ \
|
||||
return SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); \
|
||||
} \
|
||||
const T& operator()() const \
|
||||
{ \
|
||||
return SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); \
|
||||
} \
|
||||
\
|
||||
}; /* struct _member_t */ \
|
||||
\
|
||||
}; /* struct _alias_t */ \
|
||||
\
|
||||
}; /* struct SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) */ \
|
||||
\
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define SQLPP_DECLARE_TABLE(table, cols) \
|
||||
SQLPP_DECLARE_TABLE_IMPL( \
|
||||
BOOST_PP_CAT(SQLPP_WRAP_SEQUENCE_X table, 0) \
|
||||
,BOOST_PP_CAT(SQLPP_WRAP_SEQUENCE_X cols, 0) \
|
||||
)
|
||||
SQLPP_DECLARE_TABLE_IMPL(BOOST_PP_CAT(SQLPP_WRAP_SEQUENCE_X table, 0), BOOST_PP_CAT(SQLPP_WRAP_SEQUENCE_X cols, 0))
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -44,8 +44,7 @@ namespace sqlpp
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
auto _run(Db& db) const -> size_t
|
||||
{
|
||||
return db.run_prepared_execute(*this);
|
||||
}
|
||||
@ -58,7 +57,6 @@ namespace sqlpp
|
||||
_parameter_list_t params;
|
||||
mutable _prepared_statement_t _prepared_statement;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -44,8 +44,7 @@ namespace sqlpp
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
auto _run(Db& db) const -> size_t
|
||||
{
|
||||
return db.run_prepared_insert(*this);
|
||||
}
|
||||
@ -58,7 +57,6 @@ namespace sqlpp
|
||||
_parameter_list_t params;
|
||||
mutable _prepared_statement_t _prepared_statement;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -44,8 +44,7 @@ namespace sqlpp
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
auto _run(Db& db) const -> size_t
|
||||
{
|
||||
return db.run_prepared_insert(*this);
|
||||
}
|
||||
@ -58,7 +57,6 @@ namespace sqlpp
|
||||
_parameter_list_t params;
|
||||
mutable _prepared_statement_t _prepared_statement;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -46,8 +46,7 @@ namespace sqlpp
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Database& db) const
|
||||
-> result_t<decltype(db.run_prepared_select(*this)), _result_row_t>
|
||||
auto _run(Database& db) const -> result_t<decltype(db.run_prepared_select(*this)), _result_row_t>
|
||||
{
|
||||
return {db.run_prepared_select(*this), _dynamic_names};
|
||||
}
|
||||
@ -61,7 +60,6 @@ namespace sqlpp
|
||||
_dynamic_names_t _dynamic_names;
|
||||
mutable _prepared_statement_t _prepared_statement;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -44,8 +44,7 @@ namespace sqlpp
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
auto _run(Db& db) const -> size_t
|
||||
{
|
||||
return db.run_prepared_insert(*this);
|
||||
}
|
||||
@ -58,7 +57,6 @@ namespace sqlpp
|
||||
_parameter_list_t params;
|
||||
mutable _prepared_statement_t _prepared_statement;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -40,11 +40,15 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct remove_name_t {};
|
||||
struct remove_name_t
|
||||
{
|
||||
};
|
||||
struct remove_t : public statement_name_t<remove_name_t>
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::is_return_value>;
|
||||
struct _alias_t {};
|
||||
struct _alias_t
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Statement>
|
||||
struct _result_methods_t
|
||||
@ -58,8 +62,7 @@ namespace sqlpp
|
||||
|
||||
// Execute
|
||||
template <typename Db, typename Composite>
|
||||
auto _run(Db& db, const Composite& composite) const
|
||||
-> decltype(db.remove(composite))
|
||||
auto _run(Db& db, const Composite& composite) const -> decltype(db.remove(composite))
|
||||
{
|
||||
return db.remove(composite);
|
||||
}
|
||||
@ -72,22 +75,19 @@ namespace sqlpp
|
||||
|
||||
// Prepare
|
||||
template <typename Db, typename Composite>
|
||||
auto _prepare(Db& db, const Composite& composite) const
|
||||
-> prepared_remove_t<Db, Composite>
|
||||
auto _prepare(Db& db, const Composite& composite) const -> prepared_remove_t<Db, Composite>
|
||||
{
|
||||
return {{}, db.prepare_remove(composite)};
|
||||
}
|
||||
|
||||
template <typename Db>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_remove_t<Db, _statement_t>
|
||||
auto _prepare(Db& db) const -> prepared_remove_t<Db, _statement_t>
|
||||
{
|
||||
return {{}, db.prepare_remove(_get_statement())};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, remove_name_t>
|
||||
{
|
||||
@ -103,38 +103,28 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Database>
|
||||
using blank_remove_t = statement_t<Database,
|
||||
remove_t,
|
||||
no_from_t,
|
||||
no_using_t,
|
||||
no_extra_tables_t,
|
||||
no_where_t<true>
|
||||
>;
|
||||
using blank_remove_t = statement_t<Database, remove_t, no_from_t, no_using_t, no_extra_tables_t, no_where_t<true>>;
|
||||
|
||||
inline auto remove()
|
||||
-> blank_remove_t<void>
|
||||
inline auto remove() -> blank_remove_t<void>
|
||||
{
|
||||
return {blank_remove_t<void>()};
|
||||
}
|
||||
|
||||
template <typename Table>
|
||||
auto remove_from(Table table)
|
||||
-> decltype(blank_remove_t<void>().from(table))
|
||||
auto remove_from(Table table) -> decltype(blank_remove_t<void>().from(table))
|
||||
{
|
||||
return {blank_remove_t<void>().from(table)};
|
||||
}
|
||||
|
||||
template <typename Database>
|
||||
auto dynamic_remove(const Database&)
|
||||
-> decltype(blank_remove_t<Database>())
|
||||
auto dynamic_remove(const Database&) -> decltype(blank_remove_t<Database>())
|
||||
{
|
||||
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
|
||||
return {blank_remove_t<Database>()};
|
||||
}
|
||||
|
||||
template <typename Database, typename Table>
|
||||
auto dynamic_remove_from(const Database&, Table table)
|
||||
-> decltype(blank_remove_t<Database>().from(table))
|
||||
auto dynamic_remove_from(const Database&, Table table) -> decltype(blank_remove_t<Database>().from(table))
|
||||
{
|
||||
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
|
||||
return {blank_remove_t<Database>().from(table)};
|
||||
|
@ -45,9 +45,8 @@ namespace sqlpp
|
||||
result_t() = default;
|
||||
|
||||
template <typename DynamicNames>
|
||||
result_t(db_result_t&& result, const DynamicNames& dynamic_names):
|
||||
_result(std::move(result)),
|
||||
_result_row(dynamic_names)
|
||||
result_t(db_result_t&& result, const DynamicNames& dynamic_names)
|
||||
: _result(std::move(result)), _result_row(dynamic_names)
|
||||
{
|
||||
_result.next(_result_row);
|
||||
}
|
||||
@ -61,9 +60,7 @@ namespace sqlpp
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator(db_result_t& result, result_row_t& result_row):
|
||||
_result(result),
|
||||
_result_row(result_row)
|
||||
iterator(db_result_t& result, result_row_t& result_row) : _result(result), _result_row(result_row)
|
||||
{
|
||||
}
|
||||
|
||||
@ -120,7 +117,6 @@ namespace sqlpp
|
||||
{
|
||||
_result.next(_result_row);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,5 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -55,23 +55,24 @@ namespace sqlpp
|
||||
{
|
||||
using _field_spec_t = detail::get_field_spec_t<Field>;
|
||||
static constexpr bool _null_is_trivial = true;
|
||||
operator cpp_value_type_of<_field_spec_t>() const { return static_cast<const Field&>(*this).value(); }
|
||||
operator cpp_value_type_of<_field_spec_t>() const
|
||||
{
|
||||
return static_cast<const Field&>(*this).value();
|
||||
}
|
||||
};
|
||||
|
||||
template <template <typename, typename, typename> class Field, typename ValueType, typename Db, typename FieldSpec>
|
||||
struct result_field_methods_base_t<
|
||||
Field<ValueType, Db, FieldSpec>,
|
||||
typename std::enable_if<enforce_null_result_treatment_t<Db>::value
|
||||
and column_spec_can_be_null_t<FieldSpec>::value
|
||||
and not null_is_trivial_value_t<FieldSpec>::value>::type>
|
||||
struct result_field_methods_base_t<Field<ValueType, Db, FieldSpec>,
|
||||
typename std::enable_if<enforce_null_result_treatment_t<Db>::value and
|
||||
column_spec_can_be_null_t<FieldSpec>::value and
|
||||
not null_is_trivial_value_t<FieldSpec>::value>::type>
|
||||
{
|
||||
using _field_spec_t = FieldSpec;
|
||||
static constexpr bool _null_is_trivial = false;
|
||||
};
|
||||
|
||||
template <typename Field>
|
||||
struct result_field_methods_t: public result_field_methods_base_t<Field>,
|
||||
public alias_operators<Field>
|
||||
struct result_field_methods_t : public result_field_methods_base_t<Field>, public alias_operators<Field>
|
||||
{
|
||||
using _base_t = result_field_methods_base_t<Field>;
|
||||
using _field_spec_t = typename _base_t::_field_spec_t;
|
||||
@ -84,6 +85,5 @@ namespace sqlpp
|
||||
using _nodes = detail::type_vector<>;
|
||||
using _can_be_null = column_spec_can_be_null_t<_field_spec_t>;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -41,8 +41,7 @@ namespace sqlpp
|
||||
struct result_row_impl;
|
||||
|
||||
template <typename Db, std::size_t index, typename FieldSpec>
|
||||
struct result_field:
|
||||
public member_t<FieldSpec, result_field_t<value_type_of<FieldSpec>, Db, FieldSpec>>
|
||||
struct result_field : public member_t<FieldSpec, result_field_t<value_type_of<FieldSpec>, Db, FieldSpec>>
|
||||
{
|
||||
using _field = member_t<FieldSpec, result_field_t<value_type_of<FieldSpec>, Db, FieldSpec>>;
|
||||
|
||||
@ -66,10 +65,13 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <std::size_t index, typename AliasProvider, typename Db, typename... FieldSpecs>
|
||||
struct result_field<Db, index, multi_field_spec_t<AliasProvider, std::tuple<FieldSpecs...>>>:
|
||||
public member_t<AliasProvider, result_row_impl<Db, detail::make_field_index_sequence<index, FieldSpecs...>, FieldSpecs...>>
|
||||
struct result_field<Db, index, multi_field_spec_t<AliasProvider, std::tuple<FieldSpecs...>>>
|
||||
: public member_t<AliasProvider,
|
||||
result_row_impl<Db, detail::make_field_index_sequence<index, FieldSpecs...>, FieldSpecs...>>
|
||||
{
|
||||
using _multi_field = member_t<AliasProvider, result_row_impl<Db, detail::make_field_index_sequence<index, FieldSpecs...>, FieldSpecs...>>;
|
||||
using _multi_field =
|
||||
member_t<AliasProvider,
|
||||
result_row_impl<Db, detail::make_field_index_sequence<index, FieldSpecs...>, FieldSpecs...>>;
|
||||
|
||||
result_field() = default;
|
||||
|
||||
@ -91,8 +93,8 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Db, std::size_t NextIndex, std::size_t... Is, typename... FieldSpecs>
|
||||
struct result_row_impl<Db, detail::field_index_sequence<NextIndex, Is...>, FieldSpecs...>:
|
||||
public result_field<Db, Is, FieldSpecs>...
|
||||
struct result_row_impl<Db, detail::field_index_sequence<NextIndex, Is...>, FieldSpecs...>
|
||||
: public result_field<Db, Is, FieldSpecs>...
|
||||
{
|
||||
result_row_impl() = default;
|
||||
|
||||
@ -115,26 +117,23 @@ namespace sqlpp
|
||||
(void)swallow{(result_field<Db, Is, FieldSpecs>::_bind(target), 0)...};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename Db, typename... FieldSpecs>
|
||||
struct result_row_t: public detail::result_row_impl<Db, detail::make_field_index_sequence<0, FieldSpecs...>, FieldSpecs...>
|
||||
struct result_row_t
|
||||
: public detail::result_row_impl<Db, detail::make_field_index_sequence<0, FieldSpecs...>, FieldSpecs...>
|
||||
{
|
||||
using _field_index_sequence = detail::make_field_index_sequence<0, FieldSpecs...>;
|
||||
using _impl = detail::result_row_impl<Db, _field_index_sequence, FieldSpecs...>;
|
||||
bool _is_valid;
|
||||
|
||||
result_row_t():
|
||||
_impl(),
|
||||
_is_valid(false)
|
||||
result_row_t() : _impl(), _is_valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename DynamicNames>
|
||||
result_row_t(const DynamicNames&):
|
||||
_impl(),
|
||||
_is_valid(false)
|
||||
result_row_t(const DynamicNames&)
|
||||
: _impl(), _is_valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -178,7 +177,8 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Db, typename... FieldSpecs>
|
||||
struct dynamic_result_row_t: public detail::result_row_impl<Db, detail::make_field_index_sequence<0, FieldSpecs...>, FieldSpecs...>
|
||||
struct dynamic_result_row_t
|
||||
: public detail::result_row_impl<Db, detail::make_field_index_sequence<0, FieldSpecs...>, FieldSpecs...>
|
||||
{
|
||||
using _field_index_sequence = detail::make_field_index_sequence<0, FieldSpecs...>;
|
||||
using _impl = detail::result_row_impl<Db, _field_index_sequence, FieldSpecs...>;
|
||||
@ -187,7 +187,9 @@ namespace sqlpp
|
||||
using _traits = make_traits<text, tag::is_noop, tag::can_be_null, tag::null_is_trivial_value>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
|
||||
struct _alias_t {};
|
||||
struct _alias_t
|
||||
{
|
||||
};
|
||||
};
|
||||
using _field_type = result_field_t<text, Db, _field_spec_t>;
|
||||
|
||||
@ -195,16 +197,12 @@ namespace sqlpp
|
||||
std::vector<std::string> _dynamic_field_names;
|
||||
std::map<std::string, _field_type> _dynamic_fields;
|
||||
|
||||
dynamic_result_row_t():
|
||||
_impl(),
|
||||
_is_valid(false)
|
||||
dynamic_result_row_t() : _impl(), _is_valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
dynamic_result_row_t(const std::vector<std::string>& dynamic_field_names):
|
||||
_impl(),
|
||||
_is_valid(false),
|
||||
_dynamic_field_names(dynamic_field_names)
|
||||
dynamic_result_row_t(const std::vector<std::string>& dynamic_field_names)
|
||||
: _impl(), _is_valid(false), _dynamic_field_names(dynamic_field_names)
|
||||
{
|
||||
for (auto field_name : _dynamic_field_names)
|
||||
{
|
||||
@ -219,7 +217,6 @@ namespace sqlpp
|
||||
|
||||
void _validate()
|
||||
{
|
||||
|
||||
_impl::_validate();
|
||||
_is_valid = true;
|
||||
for (auto& field : _dynamic_fields)
|
||||
|
@ -111,7 +111,6 @@ namespace sqlpp
|
||||
return t.is_null();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename Expr, bool TrivialValueIsNull>
|
||||
@ -120,9 +119,9 @@ namespace sqlpp
|
||||
using _traits = typename Expr::_traits;
|
||||
using _nodes = detail::type_vector<Expr>;
|
||||
|
||||
rhs_wrap_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
rhs_wrap_t(Expr expr) : _expr(expr)
|
||||
{
|
||||
}
|
||||
|
||||
rhs_wrap_t(const rhs_wrap_t&) = default;
|
||||
rhs_wrap_t(rhs_wrap_t&&) = default;
|
||||
@ -132,8 +131,7 @@ namespace sqlpp
|
||||
|
||||
bool _is_null() const
|
||||
{
|
||||
return (TrivialValueIsNull and detail::rhs_is_trivial_t<Expr>::_(_expr))
|
||||
or detail::rhs_is_null_t<Expr>::_(_expr);
|
||||
return (TrivialValueIsNull and detail::rhs_is_trivial_t<Expr>::_(_expr)) or detail::rhs_is_null_t<Expr>::_(_expr);
|
||||
}
|
||||
|
||||
static constexpr bool _is_default()
|
||||
@ -167,7 +165,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -49,8 +49,6 @@ namespace sqlpp
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user