0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Repaired insert to work with expression values again

This commit is contained in:
rbock 2014-08-14 23:47:25 +02:00
parent d79c2ca92c
commit 3484903525
13 changed files with 213 additions and 283 deletions

View File

@ -30,9 +30,7 @@
#include <sqlpp11/default_value.h> #include <sqlpp11/default_value.h>
#include <sqlpp11/null.h> #include <sqlpp11/null.h>
#include <sqlpp11/tvin.h> #include <sqlpp11/tvin.h>
#include <sqlpp11/rhs_is_null.h> #include <sqlpp11/rhs_wrap.h>
#include <sqlpp11/rhs_is_default.h>
#include <sqlpp11/rhs_is_trivial.h>
#include <sqlpp11/serialize.h> #include <sqlpp11/serialize.h>
#include <sqlpp11/serializer.h> #include <sqlpp11/serializer.h>
#include <sqlpp11/simple_column.h> #include <sqlpp11/simple_column.h>
@ -46,7 +44,7 @@ namespace sqlpp
using _recursive_traits = make_recursive_traits<Lhs, Rhs>; using _recursive_traits = make_recursive_traits<Lhs, Rhs>;
using _lhs_t = Lhs; using _lhs_t = Lhs;
using _rhs_t = allow_tvin_t<Rhs>; using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
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");
@ -73,20 +71,8 @@ namespace sqlpp
static Context& _(const T& t, Context& context) static Context& _(const T& t, Context& context)
{ {
serialize(simple_column(t._lhs), context); serialize(simple_column(t._lhs), context);
if ((trivial_value_is_null_t<typename T::_lhs_t>::value and rhs_is_trivial(t))
or rhs_is_null(t))
{
context << "=NULL";
}
else if (rhs_is_default(t))
{
context << "=DEFAULT";
}
else
{
context << "="; context << "=";
serialize(t._rhs, context); serialize(t._rhs, context);
}
return context; return context;
} }
}; };

View File

@ -57,7 +57,7 @@ namespace sqlpp
using rhs = wrap_operand_t<T>; using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison"); static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
return { *static_cast<const Base*>(this), rhs{t} }; return { *static_cast<const Base*>(this), {rhs{t}} };
} }
template<typename T> template<typename T>
@ -66,7 +66,7 @@ namespace sqlpp
using rhs = wrap_operand_t<T>; using rhs = wrap_operand_t<T>;
static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison"); static_assert(_is_valid_comparison_operand<rhs>::value, "invalid rhs operand in comparison");
return { *static_cast<const Base*>(this), rhs{t} }; return { *static_cast<const Base*>(this), {rhs{t}} };
} }
template<typename T> template<typename T>

View File

@ -92,20 +92,20 @@ namespace sqlpp
using rhs = wrap_operand_t<T>; using rhs = wrap_operand_t<T>;
static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand assignment operand"); static_assert(_is_valid_operand<rhs>::value, "invalid rhs operand assignment operand");
return { *this, rhs{t} }; return { *this, {rhs{t}} };
} }
auto operator =(sqlpp::null_t) const auto operator =(sqlpp::null_t) const
->assignment_t<column_t, sqlpp::null_t> ->assignment_t<column_t, sqlpp::null_t>
{ {
static_assert(can_be_null_t<column_t>::value, "column cannot be null"); static_assert(can_be_null_t<column_t>::value, "column cannot be null");
return { *this, {} }; return { *this, sqlpp::null_t{} };
} }
auto operator =(sqlpp::default_value_t) const auto operator =(sqlpp::default_value_t) const
->assignment_t<column_t, sqlpp::default_value_t> ->assignment_t<column_t, sqlpp::default_value_t>
{ {
return { *this, {} }; return { *this, sqlpp::default_value_t{} };
} }
}; };

View File

@ -30,8 +30,7 @@
#include <sqlpp11/alias.h> #include <sqlpp11/alias.h>
#include <sqlpp11/boolean.h> #include <sqlpp11/boolean.h>
#include <sqlpp11/tvin.h> #include <sqlpp11/tvin.h>
#include <sqlpp11/rhs_is_null.h> #include <sqlpp11/rhs_wrap.h>
#include <sqlpp11/rhs_is_trivial.h>
#include <sqlpp11/noop.h> #include <sqlpp11/noop.h>
#include <sqlpp11/expression_fwd.h> #include <sqlpp11/expression_fwd.h>
#include <sqlpp11/serializer.h> #include <sqlpp11/serializer.h>
@ -46,7 +45,7 @@ namespace sqlpp
using _traits = make_traits<boolean, sqlpp::tag::is_expression>; using _traits = make_traits<boolean, sqlpp::tag::is_expression>;
using _recursive_traits = make_recursive_traits<Lhs, Rhs>; using _recursive_traits = make_recursive_traits<Lhs, Rhs>;
using _lhs_t = Lhs; using _lhs_t = Lhs;
using _rhs_t = allow_tvin_t<Rhs>; using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
binary_expression_t(_lhs_t lhs, _rhs_t rhs): binary_expression_t(_lhs_t lhs, _rhs_t rhs):
_lhs(lhs), _lhs(lhs),
@ -72,8 +71,7 @@ namespace sqlpp
{ {
context << "("; context << "(";
serialize(t._lhs, context); serialize(t._lhs, context);
if ((trivial_value_is_null_t<typename T::_lhs_t>::value and rhs_is_trivial(t)) if (t._rhs._is_null())
or rhs_is_null(t))
{ {
context << " IS NULL"; context << " IS NULL";
} }
@ -94,7 +92,7 @@ namespace sqlpp
using _traits = make_traits<boolean, sqlpp::tag::is_expression>; using _traits = make_traits<boolean, sqlpp::tag::is_expression>;
using _recursive_traits = make_recursive_traits<Lhs, Rhs>; using _recursive_traits = make_recursive_traits<Lhs, Rhs>;
using _lhs_t = Lhs; using _lhs_t = Lhs;
using _rhs_t = allow_tvin_t<Rhs>; using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, trivial_value_is_null_t<_lhs_t>::value>;
binary_expression_t(Lhs lhs, _rhs_t rhs): binary_expression_t(Lhs lhs, _rhs_t rhs):
_lhs(lhs), _lhs(lhs),
@ -120,8 +118,7 @@ namespace sqlpp
{ {
context << "("; context << "(";
serialize(t._lhs, context); serialize(t._lhs, context);
if ((trivial_value_is_null_t<typename T::_lhs_t>::value and rhs_is_trivial(t)) if (t._rhs._is_null())
or rhs_is_null(t))
{ {
context << " IS NOT NULL"; context << " IS NOT NULL";
} }

View File

@ -60,41 +60,35 @@ namespace sqlpp
{ {
using _is_insert_value = std::true_type; using _is_insert_value = std::true_type;
using _column_t = Column; using _column_t = Column;
static constexpr bool _trivial_value_is_null = trivial_value_is_null_t<Column>::value;
using _pure_value_t = typename value_type_of<Column>::_cpp_value_type; using _pure_value_t = typename value_type_of<Column>::_cpp_value_type;
using _wrapped_value_t = typename wrap_operand<_pure_value_t>::type; using _wrapped_value_t = typename wrap_operand<_pure_value_t>::type;
using _tvin_t = tvin_t<_wrapped_value_t>; using _tvin_t = tvin_t<_wrapped_value_t>;
insert_value_t(_wrapped_value_t rhs): insert_value_t(rhs_wrap_t<_wrapped_value_t, _trivial_value_is_null> rhs):
_is_null(false), _is_null(rhs._is_null()),
_is_default(false), _is_default(rhs._is_default()),
_value(rhs) _value(rhs._expr._t)
{} {}
insert_value_t(_tvin_t rhs): insert_value_t(rhs_wrap_t<_tvin_t, _trivial_value_is_null> rhs):
_is_null(rhs._is_trivial()), _is_null(rhs._is_null()),
_is_default(false), _is_default(rhs._is_default()),
_value(rhs._value) _value(rhs._expr._value)
{} {}
insert_value_t(const null_t&): insert_value_t(const rhs_wrap_t<null_t, _trivial_value_is_null>&):
_is_null(true), _is_null(true),
_is_default(false), _is_default(false),
_value{} _value{}
{} {}
insert_value_t(const default_value_t&): insert_value_t(const rhs_wrap_t<default_value_t, _trivial_value_is_null>&):
_is_null(false), _is_null(false),
_is_default(true), _is_default(true),
_value{} _value{}
{} {}
template<typename Db, typename FieldSpec>
insert_value_t(const result_field_t<value_type_of<Column>, Db, FieldSpec>& rhs):
_is_null(rhs.is_null()),
_is_default(false),
_value(rhs.is_null() ? _wrapped_value_t{} : rhs.value())
{}
insert_value_t(const insert_value_t&) = default; insert_value_t(const insert_value_t&) = default;
insert_value_t(insert_value_t&&) = default; insert_value_t(insert_value_t&&) = default;
insert_value_t& operator=(const insert_value_t&) = default; insert_value_t& operator=(const insert_value_t&) = default;

View File

@ -87,7 +87,7 @@ namespace sqlpp
insert_list_data_t(Assignments... assignments): insert_list_data_t(Assignments... assignments):
_assignments(assignments...), _assignments(assignments...),
_columns({assignments._lhs}...), _columns({assignments._lhs}...),
_values(insert_value_t<typename Assignments::_lhs_t>{assignments._rhs}...) _values({assignments._rhs}...)
{} {}
insert_list_data_t(const insert_list_data_t&) = default; insert_list_data_t(const insert_list_data_t&) = default;
@ -98,7 +98,7 @@ namespace sqlpp
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<typename Assignments::_lhs_t>...> _columns; std::tuple<simple_column_t<typename Assignments::_lhs_t>...> _columns;
std::tuple<insert_value_t<typename Assignments::_lhs_t>...> _values; std::tuple<typename Assignments::_rhs_t...> _values;
interpretable_list_t<Database> _dynamic_columns; interpretable_list_t<Database> _dynamic_columns;
interpretable_list_t<Database> _dynamic_values; interpretable_list_t<Database> _dynamic_values;
}; };

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2013-2014, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_RHS_IS_DEFAULT_H
#define SQLPP_RHS_IS_DEFAULT_H
#include <sqlpp11/default_value.h>
namespace sqlpp
{
template<typename T, typename Enable = void>
struct rhs_is_default_t
{
static constexpr bool _(const T&)
{
return false;
}
};
template<typename T>
struct rhs_is_default_t<T, typename std::enable_if<std::is_same<T, default_value_t>::value, void>::type>
{
static constexpr bool _(const T& t)
{
return true;
}
};
template<typename Expression>
constexpr bool rhs_is_default(const Expression& e)
{
return rhs_is_default_t<typename std::decay<Expression>::type::_rhs_t>::_(e._rhs);
}
}
#endif

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2013-2014, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_RHS_IS_NULL_H
#define SQLPP_RHS_IS_NULL_H
#include <sqlpp11/tvin.h>
#include <sqlpp11/null.h>
namespace sqlpp
{
template<typename T, typename Enable = void>
struct rhs_is_null_t
{
static constexpr bool _(const T&)
{
return false;
}
};
template<typename T>
struct rhs_is_null_t<T, typename std::enable_if<std::is_same<T, null_t>::value, void>::type>
{
static constexpr bool _(const T& t)
{
return true;
}
};
template<typename T>
struct rhs_is_null_t<T, typename std::enable_if<is_tvin_t<T>::value, void>::type>
{
static bool _(const T& t)
{
return t._is_null();
}
};
template<typename T>
struct rhs_is_null_t<T, typename std::enable_if<is_result_field_t<T>::value, void>::type>
{
static bool _(const T& t)
{
return t.is_null();
}
};
template<typename Expression>
constexpr bool rhs_is_null(const Expression& e)
{
return rhs_is_null_t<typename std::decay<Expression>::type::_rhs_t>::_(e._rhs);
}
}
#endif

View File

@ -1,91 +0,0 @@
/*
* Copyright (c) 2013-2014, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_RHS_IS_TRIVIAL_H
#define SQLPP_RHS_IS_TRIVIAL_H
#include <sqlpp11/tvin.h>
namespace sqlpp
{
template<typename T, typename Enable = void>
struct rhs_is_trivial_t
{
static constexpr bool _(const T&)
{
return false;
}
};
template<typename T>
struct rhs_is_trivial_t<T, typename std::enable_if<is_wrapped_value_t<T>::value, void>::type>
{
static bool _(const T& t)
{
return t._is_trivial();
}
};
template<typename T>
struct rhs_is_trivial_t<T, typename std::enable_if<is_tvin_t<T>::value, void>::type>
{
static bool _(const T& t)
{
return t._is_trivial();
}
};
template<typename T>
struct rhs_is_trivial_t<T, typename std::enable_if<is_result_field_t<T>::value, void>::type>
{
static bool _(const T& t)
{
if (null_is_trivial_value_t<T>::value)
{
return t._is_trivial();
}
else
{
if (t.is_null())
{
return false;
}
else
{
return t._is_trivial();
}
}
}
};
template<typename Expression>
constexpr bool rhs_is_trivial(const Expression& e)
{
return rhs_is_trivial_t<typename std::decay<Expression>::type::_rhs_t>::_(e._rhs);
}
}
#endif

172
include/sqlpp11/rhs_wrap.h Normal file
View File

@ -0,0 +1,172 @@
/*
* Copyright (c) 2013-2014, Roland Bock
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_RHS_WRAP_H
#define SQLPP_RHS_WRAP_H
#include <sqlpp11/tvin.h>
#include <sqlpp11/default_value.h>
#include <sqlpp11/null.h>
namespace sqlpp
{
namespace detail
{
template<typename Expr, typename Enable = void>
struct rhs_is_trivial_t
{
static constexpr bool _(const Expr&)
{
return false;
}
};
template<typename Expr>
struct rhs_is_trivial_t<Expr, typename std::enable_if<is_wrapped_value_t<Expr>::value, void>::type>
{
static bool _(const Expr& t)
{
return t._is_trivial();
}
};
template<typename Expr>
struct rhs_is_trivial_t<Expr, typename std::enable_if<is_tvin_t<Expr>::value, void>::type>
{
static bool _(const Expr& t)
{
return t._is_trivial();
}
};
template<typename Expr>
struct rhs_is_trivial_t<Expr, typename std::enable_if<is_result_field_t<Expr>::value, void>::type>
{
static bool _(const Expr& t)
{
if (null_is_trivial_value_t<Expr>::value)
{
return t.is_null();
}
else
{
if (t.is_null())
{
return false;
}
else
{
return t._is_trivial();
}
}
}
};
template<typename Expr, typename Enable = void>
struct rhs_is_null_t
{
static constexpr bool _(const Expr&)
{
return false;
}
};
template<typename Expr>
struct rhs_is_null_t<Expr, typename std::enable_if<is_tvin_t<Expr>::value, void>::type>
{
static bool _(const Expr& t)
{
return t._is_null();
}
};
template<typename Expr>
struct rhs_is_null_t<Expr, typename std::enable_if<is_result_field_t<Expr>::value, void>::type>
{
static bool _(const Expr& t)
{
return t.is_null();
}
};
}
template<typename Expr, bool TrivialValueIsNull>
struct rhs_wrap_t
{
using _traits = typename Expr::_traits;
using _recursive_traits = typename Expr::_recursive_traits;
rhs_wrap_t(Expr expr):
_expr(expr)
{}
rhs_wrap_t(const rhs_wrap_t&) = default;
rhs_wrap_t(rhs_wrap_t&&) = default;
rhs_wrap_t& operator=(const rhs_wrap_t&) = default;
rhs_wrap_t& operator=(rhs_wrap_t&&) = default;
~rhs_wrap_t() = default;
bool _is_null() const
{
return (TrivialValueIsNull and detail::rhs_is_trivial_t<Expr>::_(_expr))
or detail::rhs_is_null_t<Expr>::_(_expr);
}
static constexpr bool _is_default()
{
return std::is_same<Expr, default_value_t>::value;
}
Expr _expr;
};
template<typename Context, typename Expr, bool TrivialValueIsNull>
struct serializer_t<Context, rhs_wrap_t<Expr, TrivialValueIsNull>>
{
using T = rhs_wrap_t<Expr, TrivialValueIsNull>;
static Context& _(const T& t, Context& context)
{
if (t._is_null())
{
context << "NULL";
}
else if (t._is_default())
{
context << "DEFAULT";
}
else
{
serialize(t._expr, context);
}
return context;
}
};
}
#endif

View File

@ -27,6 +27,7 @@
#include "MockDb.h" #include "MockDb.h"
#include "is_regular.h" #include "is_regular.h"
#include <sqlpp11/insert.h> #include <sqlpp11/insert.h>
#include <sqlpp11/functions.h>
#include <iostream> #include <iostream>
MockDb db; MockDb db;
@ -68,7 +69,12 @@ int main()
printer.reset(); printer.reset();
std::cerr << serialize(i, printer).str() << std::endl; std::cerr << serialize(i, printer).str() << std::endl;
db(multi_insert); db(multi_insert);
db(insert_into(t).set(t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")));
db(insert_into(t).set(t.delta = sqlpp::null));
db(insert_into(t).set(t.delta = sqlpp::default_value));
return 0; return 0;
} }

View File

@ -52,8 +52,8 @@ int main()
static_assert(sqlpp::can_be_null_t<T>::value, "row.alpha can be null"); static_assert(sqlpp::can_be_null_t<T>::value, "row.alpha can be null");
static_assert(sqlpp::is_result_field_t<T>::value, "result_fields are not wrapped"); static_assert(sqlpp::is_result_field_t<T>::value, "result_fields are not wrapped");
bool x = sqlpp::rhs_is_null(t.alpha == row.alpha); bool x = (t.alpha == row.alpha)._rhs._is_null();
bool y = sqlpp::rhs_is_trivial(t.alpha == row.alpha); bool y = (t.alpha == row.alpha)._rhs._is_default();
std::cerr << x << std::endl; std::cerr << x << std::endl;
std::cerr << y << std::endl; std::cerr << y << std::endl;

View File

@ -24,7 +24,7 @@
*/ */
#include <iostream> #include <iostream>
#include <sqlpp11/update.h> #include <sqlpp11/sqlpp11.h>
#include "Sample.h" #include "Sample.h"
#include "MockDb.h" #include "MockDb.h"
#include "is_regular.h" #include "is_regular.h"
@ -64,5 +64,10 @@ int main()
db(u); db(u);
db(update(t).set(t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")).where(true));
db(update(t).set(t.delta = sqlpp::null).where(true));
db(update(t).set(t.delta = sqlpp::default_value).where(true));
return 0; return 0;
} }