diff --git a/include/sqlpp11/insert_value.h b/include/sqlpp11/insert_value.h index e78c9043..d84b9f8f 100644 --- a/include/sqlpp11/insert_value.h +++ b/include/sqlpp11/insert_value.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ namespace sqlpp using _pure_value_t = typename value_type_of::_cpp_value_type; using _wrapped_value_t = wrap_operand_t<_pure_value_t>; using _tvin_t = tvin_t<_wrapped_value_t>; + using _value_or_null_t = value_or_null_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) @@ -85,6 +87,11 @@ namespace sqlpp { } + insert_value_t(const rhs_wrap_t<_value_or_null_t, _trivial_value_is_null>& rhs) + : _is_null(rhs._expr._is_null), _is_default(false), _value{rhs._expr._value} + { + } + insert_value_t(const insert_value_t&) = default; insert_value_t(insert_value_t&&) = default; insert_value_t& operator=(const insert_value_t&) = default; diff --git a/tests/Insert.cpp b/tests/Insert.cpp index 6097b450..a364fdce 100644 --- a/tests/Insert.cpp +++ b/tests/Insert.cpp @@ -54,6 +54,8 @@ int Insert(int, char*[]) db(insert_into(t).default_values()); db(insert_into(t).set(t.gamma = true, t.beta = "kirschauflauf")); + db(insert_into(t).set(t.gamma = sqlpp::default_value, t.beta = sqlpp::value_or_null("pie"), + t.delta = sqlpp::value_or_null(sqlpp::null))); serialize(insert_into(t).default_values(), printer).str(); @@ -64,6 +66,9 @@ int Insert(int, char*[]) multi_insert.values.add(t.gamma = true, t.beta = "cheesecake", t.delta = 1); multi_insert.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::default_value, t.delta = sqlpp::default_value); + multi_insert.values.add(t.gamma = sqlpp::value_or_null(true), + t.beta = sqlpp::value_or_null("pie"), + t.delta = sqlpp::value_or_null(sqlpp::null)); auto i = dynamic_insert_into(db, t).dynamic_set(); i.insert_list.add(t.beta = "kirschauflauf"); printer.reset();