diff --git a/include/sqlpp11/concat.h b/include/sqlpp11/concat.h
index c850907b..89e576ae 100644
--- a/include/sqlpp11/concat.h
+++ b/include/sqlpp11/concat.h
@@ -56,11 +56,7 @@ namespace sqlpp
};
};
- concat_t(First&& first, Args&&... args):
- _args(std::move(first), std::move(args)...)
- {}
-
- concat_t(const First& first, const Args&... args):
+ concat_t(First first, Args... args):
_args(first, args...)
{}
diff --git a/include/sqlpp11/detail/basic_operators.h b/include/sqlpp11/detail/basic_operators.h
index a7ee0ca0..7e74fe29 100644
--- a/include/sqlpp11/detail/basic_operators.h
+++ b/include/sqlpp11/detail/basic_operators.h
@@ -73,7 +73,7 @@ namespace sqlpp
equal_t::type> operator==(T&& t) const
{
static_assert(not is_multi_expression_t::value, "multi-expression cannot be used as left hand side operand");
- return { *static_cast(this), {std::forward(t)} };
+ return { *static_cast(this), {std::forward(t)} };
}
template
@@ -100,14 +100,14 @@ namespace sqlpp
binary_expression_t::type> operator>=(T&& t) const
{
static_assert(not is_multi_expression_t::value, "multi-expression cannot be used as left hand side operand");
- return { *static_cast(this), std::forward(t) };
+ return { *static_cast(this), {std::forward(t)} };
}
template
binary_expression_t::type> operator>(T&& t) const
{
static_assert(not is_multi_expression_t::value, "multi-expression cannot be used as left hand side operand");
- return { *static_cast(this), std::forward(t) };
+ return { *static_cast(this), {std::forward(t)} };
}
is_null_t is_null() const
@@ -139,14 +139,14 @@ namespace sqlpp
in_t::type...> in(T&&... t) const
{
static_assert(not is_multi_expression_t::value, "multi-expression cannot be used with in()");
- return { *static_cast(this), std::forward(t)... };
+ return { *static_cast(this), {std::forward(t)}... };
}
template
in_t::type...> not_in(T&&... t) const
{
static_assert(not is_multi_expression_t::value, "multi-expression cannot with be used with not_in()");
- return { *static_cast(this), std::forward(t)... };
+ return { *static_cast(this), {std::forward(t)}... };
}
template
diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h
index eaa8b72f..07b49ae6 100644
--- a/include/sqlpp11/parameter.h
+++ b/include/sqlpp11/parameter.h
@@ -34,7 +34,7 @@
namespace sqlpp
{
template
- struct parameter_t
+ struct parameter_t: public ValueType::template operators>
{
using _value_type = ValueType;
using _is_parameter = std::true_type;
@@ -44,31 +44,33 @@ namespace sqlpp
static_assert(std::is_same<_trivial_value_is_null_t, std::true_type>::value or std::is_same<_trivial_value_is_null_t, std::false_type>::value, "Invalid template parameter TrivialValueIsNull");
- template
- void serialize(std::ostream& os, Db& db) const
- {
- static_assert(Db::_supports_prepared, "prepared statements not supported by current database");
- static_assert(Db::_use_questionmark_parameter or Db::_use_positional_dollar_parameter, "no known way to serialize parameter placeholders for current database");
- if (Db::_use_questionmark_parameter)
- os << '?';
- else if (Db::_use_positional_dollar_parameter)
- os << '$' << _index + 1;
- }
+ parameter_t()
+ {}
+
+ parameter_t(const parameter_t&) = default;
+ parameter_t(parameter_t&&) = default;
+ parameter_t& operator=(const parameter_t&) = default;
+ parameter_t& operator=(parameter_t&&) = default;
+ ~parameter_t() = default;
constexpr bool _is_trivial() const
{
return false;
}
-
- size_t _set_parameter_index(size_t index)
- {
- _index = index;
- return index + 1;
- }
-
- size_t _index;
};
+ template
+ struct interpreter_t>
+ {
+ using T = parameter_t;
+
+ static Context& _(const T& t, Context& context)
+ {
+ context << "?";
+ return context;
+ }
+ };
+
template::type>>
auto parameter(NamedExpr&& namedExpr)
-> parameter_t::type::_value_type, typename std::decay::type, TrivialValueIsNull>
diff --git a/include/sqlpp11/verbatim_table.h b/include/sqlpp11/verbatim_table.h
index 76661dda..c82de2e1 100644
--- a/include/sqlpp11/verbatim_table.h
+++ b/include/sqlpp11/verbatim_table.h
@@ -47,7 +47,7 @@ namespace sqlpp
};
}
- struct verbatim_table_t: public sqlpp::table_base_t
+ struct verbatim_table_t: public sqlpp::table_t
{
using _value_type = no_value_t;
diff --git a/tests/InterpretTest.cpp b/tests/InterpretTest.cpp
index 2897be57..75a25122 100644
--- a/tests/InterpretTest.cpp
+++ b/tests/InterpretTest.cpp
@@ -26,6 +26,7 @@
#include "TabSample.h"
#include "MockDb.h"
#include
+#include
#include
@@ -40,7 +41,6 @@ int main()
interpret(t.alpha, printer).flush();
interpret(t.alpha = 7, printer).flush();
interpret(t.alpha == 7, printer).flush();
- sqlpp::text_operand o = {"kaesekuchen"};
interpret(t.beta + "kaesekuchen", printer).flush();
interpret(select(sqlpp::distinct, t.alpha, t.beta), printer).flush();
@@ -51,5 +51,8 @@ int main()
interpret(select(sqlpp::distinct, t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")).order_by(t.beta.asc()), printer).flush();
interpret(select(sqlpp::distinct, t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")).order_by(t.beta.asc()).limit(17).offset(3), printer).flush();
+ interpret(parameter(t.alpha), printer).flush();
+ interpret(t.alpha == parameter(t.alpha), printer).flush();
+
return 0;
}