Fixed a bunch of small errors and shorted compile error messages

This commit is contained in:
rbock
2014-02-13 08:44:09 +01:00
parent fb092583cc
commit 9e8979c6f0
10 changed files with 116 additions and 45 deletions
+8
View File
@@ -84,6 +84,14 @@ namespace sqlpp
return { *this, {t} };
}
template<typename T>
auto operator =(T t) const
-> typename std::enable_if<not(_value_type::template _constraint<typename vendor::wrap_operand<T>::type>::value and not std::is_same<column_t, T>::value),
vendor::assignment_t<column_t, typename vendor::wrap_operand<T>::type>>::type
{
static_assert(sqlpp::vendor::wrong_t<T>::value, "invalid assignment operand");
}
auto operator =(sqlpp::null_t) const
->vendor::assignment_t<column_t, sqlpp::null_t>
{
+1 -1
View File
@@ -475,7 +475,7 @@ namespace sqlpp
const _dynamic_names_t& get_dynamic_names() const
{
return _column_list_t::_dynamic_columns._dynamic_expression_names;
return _column_list._dynamic_columns._dynamic_expression_names;
}
static constexpr size_t _get_static_no_of_parameters()
+6
View File
@@ -179,6 +179,12 @@ namespace sqlpp
return { *static_cast<const Base*>(this), {t} };
}
template<typename T>
auto operator +=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() + t)
{
return *static_cast<const Base*>(this) = operator +(t);
}
template<typename T>
vendor::like_t<Base, typename _operand_t<T>::type> like(T t) const
{
+1 -3
View File
@@ -157,9 +157,7 @@ namespace sqlpp
}
template<typename... Assignments>
void add_values_impl(const std::false_type&, Assignments... assignments)
{
}
void add_values_impl(const std::false_type&, Assignments... assignments);
};
+3 -1
View File
@@ -47,7 +47,8 @@ namespace sqlpp
using _parameter_tuple_t = std::tuple<Expressions...>;
static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression argument required in where()");
static_assert(sqlpp::detail::and_t<is_expression_t, Expressions...>::value, "at least one argument is not an expression in where()");
static_assert(not sqlpp::detail::or_t<is_assignment_t, Expressions...>::value, "at least one argument is an assignment in where()");
static_assert(sqlpp::detail::and_t<is_expression_t, Expressions...>::value, "at least one argument is not valid expression in where()");
using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type;
@@ -80,6 +81,7 @@ namespace sqlpp
{
using _is_where = std::true_type;
using _is_dynamic = std::false_type;
using _table_set = ::sqlpp::detail::type_set<>;
where_t(bool condition):
_condition(condition)
+88 -34
View File
@@ -50,6 +50,20 @@ namespace sqlpp
using _value_t = bool;
using _table_set = ::sqlpp::detail::type_set<>;
boolean_operand():
_t{}
{}
boolean_operand(_value_t t):
_t(t)
{}
boolean_operand(const boolean_operand&) = default;
boolean_operand(boolean_operand&&) = default;
boolean_operand& operator=(const boolean_operand&) = default;
boolean_operand& operator=(boolean_operand&&) = default;
~boolean_operand() = default;
bool _is_trivial() const { return _t == false; }
_value_t _t;
@@ -67,23 +81,36 @@ namespace sqlpp
}
};
template<typename T>
struct integral_operand
struct integral_operand
{
static constexpr bool _is_expression = true;
using _value_type = ::sqlpp::detail::integral;
using _value_t = int64_t;
using _table_set = ::sqlpp::detail::type_set<>;
integral_operand():
_t{}
{}
integral_operand(_value_t t):
_t(t)
{}
integral_operand(const integral_operand&) = default;
integral_operand(integral_operand&&) = default;
integral_operand& operator=(const integral_operand&) = default;
integral_operand& operator=(integral_operand&&) = default;
~integral_operand() = default;
bool _is_trivial() const { return _t == 0; }
_value_t _t;
};
template<typename Context>
struct interpreter_t<Context, integral_operand>
{
static constexpr bool _is_expression = true;
using _value_type = ::sqlpp::detail::integral;
using _value_t = T;
using _table_set = ::sqlpp::detail::type_set<>;
bool _is_trivial() const { return _t == 0; }
_value_t _t;
};
template<typename Context, typename T>
struct interpreter_t<Context, integral_operand<T>>
{
using Operand = integral_operand<T>;
using Operand = integral_operand;
static Context& _(const Operand& t, Context& context)
{
@@ -93,23 +120,36 @@ namespace sqlpp
};
template<typename T>
struct floating_point_operand
struct floating_point_operand
{
static constexpr bool _is_expression = true;
using _value_type = ::sqlpp::detail::floating_point;
using _value_t = double;
using _table_set = ::sqlpp::detail::type_set<>;
floating_point_operand():
_t{}
{}
floating_point_operand(_value_t t):
_t(t)
{}
floating_point_operand(const floating_point_operand&) = default;
floating_point_operand(floating_point_operand&&) = default;
floating_point_operand& operator=(const floating_point_operand&) = default;
floating_point_operand& operator=(floating_point_operand&&) = default;
~floating_point_operand() = default;
bool _is_trivial() const { return _t == 0; }
_value_t _t;
};
template<typename Context>
struct interpreter_t<Context, floating_point_operand>
{
static constexpr bool _is_expression = true;
using _value_type = ::sqlpp::detail::floating_point;
using _value_t = T;
using _table_set = ::sqlpp::detail::type_set<>;
bool _is_trivial() const { return _t == 0; }
_value_t _t;
};
template<typename Context, typename T>
struct interpreter_t<Context, floating_point_operand<T>>
{
using Operand = floating_point_operand<T>;
using Operand = floating_point_operand;
static Context& _(const Operand& t, Context& context)
{
@@ -125,6 +165,20 @@ namespace sqlpp
using _value_t = std::string;
using _table_set = ::sqlpp::detail::type_set<>;
text_operand():
_t{}
{}
text_operand(_value_t t):
_t(t)
{}
text_operand(const text_operand&) = default;
text_operand(text_operand&&) = default;
text_operand& operator=(const text_operand&) = default;
text_operand& operator=(text_operand&&) = default;
~text_operand() = default;
bool _is_trivial() const { return _t.empty(); }
_value_t _t;
@@ -157,13 +211,13 @@ namespace sqlpp
template<typename T>
struct wrap_operand<T, typename std::enable_if<std::is_integral<T>::value>::type>
{
using type = integral_operand<T>;
using type = integral_operand;
};
template<typename T>
struct wrap_operand<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
{
using type = floating_point_operand<T>;
using type = floating_point_operand;
};
template<typename T>
+1
View File
@@ -19,5 +19,6 @@ find_package(PythonInterp REQUIRED)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_LIST_DIR}/Sample.h
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/ddl2cpp ${CMAKE_CURRENT_LIST_DIR}/sample.sql Sample test
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/sample.sql
)
+3 -2
View File
@@ -62,8 +62,9 @@ int main()
interpret(insert_into(t), printer).flush();
interpret(insert_into(t).set(t.beta = "kirschauflauf"), printer).flush();
interpret(insert_into(t).columns(t.beta), printer).flush();
auto multi_insert = insert_into(t).columns(t.beta);
multi_insert.add_values(t.beta = "cheesecake");
auto multi_insert = insert_into(t).columns(t.beta, t.delta);
multi_insert.add_values(t.beta = "cheesecake", t.delta = 1);
multi_insert.add_values(t.beta = sqlpp::default_value, t.delta = sqlpp::default_value);
auto i = dynamic_insert_into(db, t).dynamic_set();
i.add_set(t.beta = "kirschauflauf");
interpret(i, printer).flush();
+3 -3
View File
@@ -273,7 +273,7 @@ int main()
// Test that select(all_of(tab)) is expanded in select
{
auto a = select(all_of(t));
auto b = select(t.alpha, t.beta, t.gamma);
auto b = select(t.alpha, t.beta, t.gamma, t.delta);
//auto c = select(t);
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by select()");
//static_assert(std::is_same<decltype(b), decltype(c)>::value, "t has to be expanded by select()");
@@ -282,14 +282,14 @@ int main()
// Test that select(all_of(tab)) is expanded in multi_column
{
auto a = multi_column(alias::a, all_of(t));
auto b = multi_column(alias::a, t.alpha, t.beta, t.gamma);
auto b = multi_column(alias::a, t.alpha, t.beta, t.gamma, t.delta);
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by multi_column");
}
// Test that select(tab) is expanded in multi_column
{
auto a = multi_column(alias::a, all_of(t));
auto b = multi_column(alias::a, t.alpha, t.beta, t.gamma);
auto b = multi_column(alias::a, t.alpha, t.beta, t.gamma, t.delta);
static_assert(std::is_same<decltype(a), decltype(b)>::value, "t has to be expanded by multi_column");
}
+2 -1
View File
@@ -35,6 +35,7 @@ CREATE TABLE tab_bar
(
alpha bigint AUTO_INCREMENT,
beta varchar(255) NULL DEFAULT "",
gamma bool NOT NULL
gamma bool NOT NULL,
delta int
);