0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Merge branch 'release/0.33'

This commit is contained in:
rbock 2015-03-22 12:31:49 +01:00
commit 9d7d83b906
27 changed files with 107 additions and 106 deletions

View File

@ -27,13 +27,13 @@
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
int main()
{
MockDb db; MockDb db;
test::TabPerson p; test::TabPerson p;
test::TabFeature f; test::TabFeature f;
int main()
{
db(insert_into(f).set(f.name = "loves c++", f.fatal = false)); db(insert_into(f).set(f.name = "loves c++", f.fatal = false));
//db(insert_into(f).set(f.nahme = "loves c++", f.fatal = false)); //db(insert_into(f).set(f.nahme = "loves c++", f.fatal = false));

View File

@ -61,7 +61,8 @@ SQLPP_DECLARE_TABLE(
(fatal, bool , SQLPP_NOT_NULL ) (fatal, bool , SQLPP_NOT_NULL )
) )
int main() { int main()
{
MockDb db; MockDb db;
tab_person::tab_person p; tab_person::tab_person p;
tab_feature::tab_feature f; tab_feature::tab_feature f;

View File

@ -27,13 +27,13 @@
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
int main()
{
MockDb db; MockDb db;
test::TabPerson p; test::TabPerson p;
test::TabFeature q; test::TabFeature q;
int main()
{
db(remove_from(p) db(remove_from(p)
.using_(p, q) .using_(p, q)
.where(p.feature == q.id and q.fatal == true)); .where(p.feature == q.id and q.fatal == true));

View File

@ -27,13 +27,13 @@
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
int main()
{
MockDb db; MockDb db;
test::TabPerson p; test::TabPerson p;
test::TabFeature f; test::TabFeature f;
int main()
{
db(insert_into(f).set(f.name = "Loves C++", p.fatal = false)); db(insert_into(f).set(f.name = "Loves C++", p.fatal = false));
db(insert_into(f).set(p.name = "Roland", p.feature = 1)); db(insert_into(f).set(p.name = "Roland", p.feature = 1));

View File

@ -34,18 +34,18 @@
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
SQLPP_ALIAS_PROVIDER(cheesecake)
int main()
{
static constexpr bool some_condition = true; static constexpr bool some_condition = true;
static constexpr bool some_other_condition = false; static constexpr bool some_other_condition = false;
SQLPP_ALIAS_PROVIDER(cheesecake)
MockDb db; MockDb db;
test::TabPerson p; test::TabPerson p;
test::TabFeature f; test::TabFeature f;
int main()
{
for (const auto& row : db(select(all_of(p)).from(p).where(p.id > 7))) for (const auto& row : db(select(all_of(p)).from(p).where(p.id > 7)))
{ {
int64_t id = row.id; int64_t id = row.id;

View File

@ -27,12 +27,12 @@
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
int main()
{
MockDb db; MockDb db;
test::TabPerson p; test::TabPerson p;
test::TabFeature q; //test::TabFeature q;
int main()
{
db(update(p).set(p.feature = 7).where(p.id == 23)); db(update(p).set(p.feature = 7).where(p.id == 23));
} }

View File

@ -60,14 +60,14 @@ namespace sqlpp
_is_null(true) _is_null(true)
{} {}
parameter_value_t(const _cpp_value_type& value): parameter_value_t(const _cpp_value_type& val):
_value(value), _value(val),
_is_null(false) _is_null(false)
{} {}
parameter_value_t& operator=(const _cpp_value_type& value) parameter_value_t& operator=(const _cpp_value_type& val)
{ {
_value = value; _value = val;
_is_null = false; _is_null = false;
return *this; return *this;
} }

View File

@ -64,9 +64,9 @@ namespace sqlpp
}; };
template<typename Context, typename Lhs, typename Rhs> template<typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, equal_to_t<Lhs, Rhs>> struct serializer_t<Context, binary_expression_t<Lhs, op::equal_to, Rhs>>
{ {
using T = equal_to_t<Lhs, Rhs>; using T = binary_expression_t<Lhs, op::equal_to, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>; using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context) static Context& _(const T& t, Context& context)
@ -113,9 +113,9 @@ namespace sqlpp
}; };
template<typename Context, typename Lhs, typename Rhs> template<typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, not_equal_to_t<Lhs, Rhs>> struct serializer_t<Context, binary_expression_t<Lhs, op::not_equal_to, Rhs>>
{ {
using T = not_equal_to_t<Lhs, Rhs>; using T = binary_expression_t<Lhs, op::not_equal_to, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>; using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context) static Context& _(const T& t, Context& context)
@ -158,10 +158,10 @@ namespace sqlpp
}; };
template<typename Context, typename Rhs> template<typename Context, typename Rhs>
struct serializer_t<Context, logical_not_t<Rhs>> struct serializer_t<Context, unary_expression_t<op::logical_not, Rhs>>
{ {
using _serialize_check = serialize_check_of<Context, Rhs>; using _serialize_check = serialize_check_of<Context, Rhs>;
using T = logical_not_t<Rhs>; using T = unary_expression_t<op::logical_not, Rhs>;
static Context& _(const T& t, Context& context) static Context& _(const T& t, Context& context)
{ {

View File

@ -58,14 +58,14 @@ namespace sqlpp
_is_null(true) _is_null(true)
{} {}
parameter_value_t(const _cpp_value_type& value): parameter_value_t(const _cpp_value_type& val):
_value(value), _value(val),
_is_null(false) _is_null(false)
{} {}
parameter_value_t& operator=(const _cpp_value_type& value) parameter_value_t& operator=(const _cpp_value_type& val)
{ {
_value = value; _value = val;
_is_null = false; _is_null = false;
return *this; return *this;
} }

View File

@ -215,8 +215,8 @@ namespace sqlpp
template<typename... Columns> template<typename... Columns>
struct column_list_data_t struct column_list_data_t
{ {
column_list_data_t(Columns... columns): column_list_data_t(Columns... cols):
_columns(simple_column_t<Columns>{columns}...) _columns(simple_column_t<Columns>{cols}...)
{} {}
column_list_data_t(const column_list_data_t&) = default; column_list_data_t(const column_list_data_t&) = default;
@ -370,13 +370,13 @@ namespace sqlpp
} }
template<typename... Columns> template<typename... Columns>
auto columns(Columns... columns) const auto columns(Columns... cols) const
-> _new_statement_t<_column_check<Columns...>, column_list_t<Columns...>> -> _new_statement_t<_column_check<Columns...>, column_list_t<Columns...>>
{ {
static_assert(logic::all_t<is_column_t<Columns>::value...>::value, "at least one argument is not a column in columns()"); static_assert(logic::all_t<is_column_t<Columns>::value...>::value, "at least one argument is not a column in columns()");
static_assert(sizeof...(Columns), "at least one column required in columns()"); static_assert(sizeof...(Columns), "at least one column required in columns()");
return _columns_impl(_column_check<Columns...>{}, columns...); return _columns_impl(_column_check<Columns...>{}, cols...);
} }
template<typename... Assignments> template<typename... Assignments>
@ -400,11 +400,11 @@ namespace sqlpp
} }
private: private:
template<typename... Columns> template<typename... Columns>
auto _columns_impl(const std::false_type&, Columns... columns) const auto _columns_impl(const std::false_type&, Columns... cols) const
-> bad_statement; -> bad_statement;
template<typename... Columns> template<typename... Columns>
auto _columns_impl(const std::true_type&, Columns... columns) const auto _columns_impl(const std::true_type&, Columns... cols) const
-> _new_statement_t<std::true_type, column_list_t<Columns...>> -> _new_statement_t<std::true_type, column_list_t<Columns...>>
{ {
static_assert(not detail::has_duplicates<Columns...>::value, "at least one duplicate argument detected in columns()"); static_assert(not detail::has_duplicates<Columns...>::value, "at least one duplicate argument detected in columns()");
@ -414,7 +414,7 @@ namespace sqlpp
static_assert(detail::have_all_required_columns<Columns...>::value, "At least one required column is missing in columns()"); static_assert(detail::have_all_required_columns<Columns...>::value, "At least one required column is missing in columns()");
return { static_cast<const derived_statement_t<Policies>&>(*this), column_list_data_t<Columns...>{columns...} }; return { static_cast<const derived_statement_t<Policies>&>(*this), column_list_data_t<Columns...>{cols...} };
} }
template<typename Database, typename... Assignments> template<typename Database, typename... Assignments>

View File

@ -60,14 +60,14 @@ namespace sqlpp
_is_null(true) _is_null(true)
{} {}
explicit parameter_value_t(const _cpp_value_type& value): explicit parameter_value_t(const _cpp_value_type& val):
_value(value), _value(val),
_is_null(false) _is_null(false)
{} {}
parameter_value_t& operator=(const _cpp_value_type& value) parameter_value_t& operator=(const _cpp_value_type& val)
{ {
_value = value; _value = val;
_is_null = false; _is_null = false;
return *this; return *this;
} }

View File

@ -206,9 +206,9 @@ namespace sqlpp
_is_valid(false), _is_valid(false),
_dynamic_field_names(dynamic_field_names) _dynamic_field_names(dynamic_field_names)
{ {
for (auto name : _dynamic_field_names) for (auto field_name : _dynamic_field_names)
{ {
_dynamic_fields.insert({name, _field_type{}}); _dynamic_fields.insert({field_name, _field_type{}});
} }
} }
@ -259,9 +259,9 @@ namespace sqlpp
_impl::_bind(target); _impl::_bind(target);
std::size_t index = _field_index_sequence::_next_index; std::size_t index = _field_index_sequence::_next_index;
for (const auto& name : _dynamic_field_names) for (const auto& field_name : _dynamic_field_names)
{ {
_dynamic_fields.at(name)._bind(target, index); _dynamic_fields.at(field_name)._bind(target, index);
++index; ++index;
} }
} }

View File

@ -41,8 +41,8 @@ namespace sqlpp
template<typename Database, typename... Flags> template<typename Database, typename... Flags>
struct select_flag_list_data_t struct select_flag_list_data_t
{ {
select_flag_list_data_t(Flags... flags): select_flag_list_data_t(Flags... flgs):
_flags(flags...) _flags(flgs...)
{} {}
select_flag_list_data_t(const select_flag_list_data_t&) = default; select_flag_list_data_t(const select_flag_list_data_t&) = default;
@ -167,36 +167,36 @@ namespace sqlpp
using _consistency_check = consistent_t; using _consistency_check = consistent_t;
template<typename... Flags> template<typename... Flags>
auto flags(Flags... flags) const auto flags(Flags... flgs) const
-> _new_statement_t<_check<Flags...>, select_flag_list_t<void, Flags...>> -> _new_statement_t<_check<Flags...>, select_flag_list_t<void, Flags...>>
{ {
static_assert(_check<Flags...>::value, "at least one argument is not a select flag in select flag list"); static_assert(_check<Flags...>::value, "at least one argument is not a select flag in select flag list");
return _flags_impl<void>(_check<Flags...>{}, flags...); return _flags_impl<void>(_check<Flags...>{}, flgs...);
} }
template<typename... Flags> template<typename... Flags>
auto dynamic_flags(Flags... flags) const auto dynamic_flags(Flags... flgs) const
-> _new_statement_t<_check<Flags...>, select_flag_list_t<_database_t, Flags...>> -> _new_statement_t<_check<Flags...>, select_flag_list_t<_database_t, Flags...>>
{ {
static_assert(not std::is_same<_database_t, void>::value, "dynamic_flags must not be called in a static statement"); static_assert(not std::is_same<_database_t, void>::value, "dynamic_flags must not be called in a static statement");
static_assert(_check<Flags...>::value, "at least one argument is not a select flag in select flag list"); static_assert(_check<Flags...>::value, "at least one argument is not a select flag in select flag list");
return _flags_impl<_database_t>(_check<Flags...>{}, flags...); return _flags_impl<_database_t>(_check<Flags...>{}, flgs...);
} }
private: private:
template<typename Database, typename... Flags> template<typename Database, typename... Flags>
auto _flags_impl(const std::false_type&, Flags... flags) const auto _flags_impl(const std::false_type&, Flags... flgs) const
-> bad_statement; -> bad_statement;
template<typename Database, typename... Flags> template<typename Database, typename... Flags>
auto _flags_impl(const std::true_type&, Flags... flags) const auto _flags_impl(const std::true_type&, Flags... flgs) const
-> _new_statement_t<std::true_type, select_flag_list_t<Database, Flags...>> -> _new_statement_t<std::true_type, select_flag_list_t<Database, Flags...>>
{ {
static_assert(not detail::has_duplicates<Flags...>::value, "at least one duplicate argument detected in select flag list"); static_assert(not detail::has_duplicates<Flags...>::value, "at least one duplicate argument detected in select flag list");
return { static_cast<const derived_statement_t<Policies>&>(*this), select_flag_list_data_t<Database, Flags...>{flags...} }; return { static_cast<const derived_statement_t<Policies>&>(*this), select_flag_list_data_t<Database, Flags...>{flgs...} };
} }
}; };

View File

@ -59,14 +59,14 @@ namespace sqlpp
_is_null(true) _is_null(true)
{} {}
parameter_value_t(const _cpp_value_type& value): parameter_value_t(const _cpp_value_type& val):
_value(value), _value(val),
_is_null(false) _is_null(false)
{} {}
parameter_value_t& operator=(const _cpp_value_type& value) parameter_value_t& operator=(const _cpp_value_type& val)
{ {
_value = value; _value = val;
_is_null = false; _is_null = false;
return *this; return *this;
} }

View File

@ -28,10 +28,10 @@
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
MockDb db = {};
int main() int main()
{ {
MockDb db = {};
test::TabBar t; test::TabBar t;
auto x = boolean_expression(db, t.alpha == 7); auto x = boolean_expression(db, t.alpha == 7);

View File

@ -29,11 +29,11 @@
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
#include <sqlpp11/custom_query.h> #include <sqlpp11/custom_query.h>
int main()
{
MockDb db = {}; MockDb db = {};
MockDb::_serializer_context_t printer; MockDb::_serializer_context_t printer;
int main()
{
test::TabFoo f; test::TabFoo f;
test::TabBar t; test::TabBar t;

View File

@ -32,11 +32,11 @@
#include <iostream> #include <iostream>
MockDb db = {};
SQLPP_ALIAS_PROVIDER(kaesekuchen) SQLPP_ALIAS_PROVIDER(kaesekuchen)
int main() int main()
{ {
MockDb db = {};
test::TabFoo f; test::TabFoo f;
test::TabBar t; test::TabBar t;

View File

@ -30,11 +30,11 @@
#include <sqlpp11/functions.h> #include <sqlpp11/functions.h>
#include <iostream> #include <iostream>
MockDb db;
MockDb::_serializer_context_t printer;
int main() int main()
{ {
MockDb db;
MockDb::_serializer_context_t printer;
test::TabBar t; test::TabBar t;
//test::TabFoo f; //test::TabFoo f;

View File

@ -29,11 +29,11 @@
#include <iostream> #include <iostream>
int main()
{
MockDb db = {}; MockDb db = {};
MockDb::_serializer_context_t printer; MockDb::_serializer_context_t printer;
int main()
{
test::TabFoo f; test::TabFoo f;
test::TabBar t; test::TabBar t;

View File

@ -31,10 +31,10 @@
#include <iostream> #include <iostream>
MockDb db = {};
int main() int main()
{ {
MockDb db = {};
//test::TabFoo f; //test::TabFoo f;
test::TabBar t; test::TabBar t;

View File

@ -30,11 +30,11 @@
#include "is_regular.h" #include "is_regular.h"
int main()
{
MockDb db; MockDb db;
MockDb::_serializer_context_t printer; MockDb::_serializer_context_t printer;
int main()
{
test::TabBar t; test::TabBar t;
{ {

View File

@ -32,11 +32,11 @@
static_assert(not sqlpp::enforce_null_result_treatment_t<MockDb>::value, "MockDb interprets NULL as trivial"); static_assert(not sqlpp::enforce_null_result_treatment_t<MockDb>::value, "MockDb interprets NULL as trivial");
static_assert(sqlpp::enforce_null_result_treatment_t<EnforceDb>::value, "MockDb does not interpret NULL as trivial"); static_assert(sqlpp::enforce_null_result_treatment_t<EnforceDb>::value, "MockDb does not interpret NULL as trivial");
int main()
{
MockDb db = {}; MockDb db = {};
EnforceDb edb {}; EnforceDb edb {};
int main()
{
test::TabBar t; test::TabBar t;
static_assert(sqlpp::can_be_null_t<decltype(t.alpha)>::value, "t.alpha can be null"); static_assert(sqlpp::can_be_null_t<decltype(t.alpha)>::value, "t.alpha can be null");

View File

@ -33,11 +33,8 @@
#include <sqlpp11/connection.h> #include <sqlpp11/connection.h>
MockDb db = {}; template<typename Db, typename Column>
MockDb::_serializer_context_t printer; int64_t getColumn(Db&& db, const Column& column)
template<typename Column>
int64_t getColumn(const Column& column)
{ {
auto result = db(select(column.as(sqlpp::alias::a)).from(column.table()).where(true)); auto result = db(select(column.as(sqlpp::alias::a)).from(column.table()).where(true));
if (not result.empty()) if (not result.empty())
@ -48,10 +45,13 @@ int64_t getColumn(const Column& column)
int main() int main()
{ {
MockDb db = {};
MockDb::_serializer_context_t printer;
test::TabFoo f; test::TabFoo f;
test::TabBar t; test::TabBar t;
getColumn(t.alpha); getColumn(db, t.alpha);
for (const auto& row : db(select(all_of(t)).from(t).where(true))) for (const auto& row : db(select(all_of(t)).from(t).where(true)))
{ {

View File

@ -33,9 +33,6 @@
#include <sqlpp11/connection.h> #include <sqlpp11/connection.h>
MockDb db = {};
MockDb::_serializer_context_t printer;
namespace alias namespace alias
{ {
SQLPP_ALIAS_PROVIDER(a) SQLPP_ALIAS_PROVIDER(a)
@ -46,6 +43,9 @@ namespace alias
int main() int main()
{ {
MockDb db = {};
MockDb::_serializer_context_t printer;
test::TabFoo f; test::TabFoo f;
test::TabBar t; test::TabBar t;

View File

@ -29,11 +29,11 @@
#include <sqlpp11/alias_provider.h> #include <sqlpp11/alias_provider.h>
#include <iostream> #include <iostream>
int main()
{
MockDb db; MockDb db;
MockDb::_serializer_context_t printer; MockDb::_serializer_context_t printer;
int main()
{
test::TabBar t; test::TabBar t;
test::TabFoo f; test::TabFoo f;

View File

@ -29,11 +29,11 @@
#include "MockDb.h" #include "MockDb.h"
#include "is_regular.h" #include "is_regular.h"
int main()
{
MockDb db; MockDb db;
MockDb::_serializer_context_t printer; MockDb::_serializer_context_t printer;
int main()
{
test::TabBar t; test::TabBar t;
//test::TabFoo f; //test::TabFoo f;

View File

@ -29,11 +29,11 @@
#include <sqlpp11/alias_provider.h> #include <sqlpp11/alias_provider.h>
#include <iostream> #include <iostream>
int main()
{
MockDb db; MockDb db;
MockDb::_serializer_context_t printer; MockDb::_serializer_context_t printer;
int main()
{
const auto t = test::TabBar{}; const auto t = test::TabBar{};
auto x = sqlpp::cte(sqlpp::alias::x).as(select(all_of(t)).from(t)); auto x = sqlpp::cte(sqlpp::alias::x).as(select(all_of(t)).from(t));