mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-06 21:20:42 -06:00
Added tvin arguments for parameters
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <sqlpp11/basic_expression_operators.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/exception.h>
|
||||
#include <sqlpp11/tvin.h>
|
||||
#include <sqlpp11/result_field.h>
|
||||
|
||||
namespace sqlpp
|
||||
@@ -60,7 +61,22 @@ namespace sqlpp
|
||||
_parameter_t& operator=(const _cpp_value_type& value)
|
||||
{
|
||||
_value = value;
|
||||
_is_null = (false);
|
||||
_is_null = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = false;
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,21 @@ namespace sqlpp
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = 0;
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
_value = 0;
|
||||
|
||||
@@ -64,6 +64,21 @@ namespace sqlpp
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const tvin_t<wrap_operand_t<_cpp_value_type>>& t)
|
||||
{
|
||||
if (t._is_trivial())
|
||||
{
|
||||
_value = "";
|
||||
_is_null = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = t._value._t;
|
||||
_is_null = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_parameter_t& operator=(const std::nullptr_t&)
|
||||
{
|
||||
_value = "";
|
||||
|
||||
@@ -152,9 +152,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Operand>
|
||||
auto tvin(Operand operand) -> tvin_arg_t<typename wrap_operand<Operand>::type>
|
||||
auto tvin(Operand operand) -> tvin_arg_t<wrap_operand_t<Operand>>
|
||||
{
|
||||
using _operand_t = typename wrap_operand<Operand>::type;
|
||||
using _operand_t = wrap_operand_t<Operand>;
|
||||
static_assert(not std::is_same<_operand_t, Operand>::value or is_result_field_t<Operand>::value, "tvin() used with invalid type (only string and primitive types allowed)");
|
||||
return {{operand}};
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ int main()
|
||||
auto s = select(all_of(t)).from(t).where((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma));
|
||||
auto p = db.prepare(s);
|
||||
p.params.alpha = 7;
|
||||
p.params.alpha = sqlpp::tvin(0);
|
||||
using S = decltype(s);
|
||||
using T = sqlpp::make_parameter_list_t<S>;
|
||||
T npl;
|
||||
|
||||
Reference in New Issue
Block a user