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

Fixed a bunch of warnings

This commit is contained in:
rbock 2014-06-26 08:39:08 +02:00
parent 1267aa252f
commit e03366202d
7 changed files with 34 additions and 37 deletions

View File

@ -30,7 +30,6 @@
#include <sqlpp11/alias.h> #include <sqlpp11/alias.h>
#include <sqlpp11/sort_order.h> #include <sqlpp11/sort_order.h>
#include <sqlpp11/expression_fwd.h> #include <sqlpp11/expression_fwd.h>
#include <sqlpp11/assignment.h>
#include <sqlpp11/in_fwd.h> #include <sqlpp11/in_fwd.h>
#include <sqlpp11/is_null_fwd.h> #include <sqlpp11/is_null_fwd.h>
#include <sqlpp11/wrap_operand.h> #include <sqlpp11/wrap_operand.h>

View File

@ -33,6 +33,7 @@
#include <sqlpp11/type_traits.h> #include <sqlpp11/type_traits.h>
#include <sqlpp11/exception.h> #include <sqlpp11/exception.h>
#include <sqlpp11/value_type.h> #include <sqlpp11/value_type.h>
#include <sqlpp11/assignment.h>
namespace sqlpp namespace sqlpp
{ {

View File

@ -56,7 +56,6 @@ namespace sqlpp
template<typename Column> template<typename Column>
simple_column_t<Column> simple_column(Column c) simple_column_t<Column> simple_column(Column c)
{ {
#warning: make sure that there are no parameters in Column
return {c}; return {c};
} }
} }

View File

@ -141,7 +141,7 @@ namespace sqlpp
using _new_statement_t = typename Policies::template _new_statement_t<no_single_table_t, T>; using _new_statement_t = typename Policies::template _new_statement_t<no_single_table_t, T>;
static void _check_consistency() {} static void _check_consistency() {}
#warning: remove can operate on several tables at once, so it should not use single_table anyway
template<typename... Args> template<typename... Args>
auto from(Args... args) auto from(Args... args)
-> _new_statement_t<single_table_t<void, Args...>> -> _new_statement_t<single_table_t<void, Args...>>

View File

@ -48,7 +48,6 @@ namespace sqlpp
template<typename Db = void, typename... Policies> template<typename Db = void, typename... Policies>
struct statement_policies_t struct statement_policies_t
{ {
#warning need to check policies' signature, e.g. a _data_t in _member_t template
using _database_t = Db; using _database_t = Db;
using _statement_t = statement_t<Db, Policies...>; using _statement_t = statement_t<Db, Policies...>;
@ -166,8 +165,6 @@ namespace sqlpp
static void _check_consistency() static void _check_consistency()
{ {
// FIXME: Check each "methods" or each member...
#warning check for missing terms here, and for missing tables
static_assert(not required_tables_of<_policies_t>::size::value, "one sub expression requires tables which are otherwise not known in the statement"); static_assert(not required_tables_of<_policies_t>::size::value, "one sub expression requires tables which are otherwise not known in the statement");
using swallow = int[]; using swallow = int[];

View File

@ -60,23 +60,6 @@ namespace sqlpp
using _recursive_traits = make_recursive_traits<Assignments...>; using _recursive_traits = make_recursive_traits<Assignments...>;
using _is_dynamic = is_database<Database>; using _is_dynamic = is_database<Database>;
static_assert(_is_dynamic::value or sizeof...(Assignments), "at least one assignment expression required in set()");
static_assert(not ::sqlpp::detail::has_duplicates<Assignments...>::value, "at least one duplicate argument detected in set()");
static_assert(::sqlpp::detail::all_t<is_assignment_t<Assignments>::value...>::value, "at least one argument is not an assignment in set()");
static_assert(::sqlpp::detail::none_t<must_not_update_t<typename Assignments::_column_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()");
#warning reactivate tests
/*
using _column_table_set = typename ::sqlpp::detail::make_joined_set<typename Assignments::_column_t::_table_set...>::type;
using _value_table_set = typename ::sqlpp::detail::make_joined_set<typename Assignments::value_type::_table_set...>::type;
using _table_set = typename ::sqlpp::detail::make_joined_set<_column_table_set, _value_table_set>::type;
static_assert(sizeof...(Assignments) ? (_column_table_set::size::value == 1) : true, "set() contains assignments for tables from several columns");
static_assert(::sqlpp::detail::is_subset_of<_value_table_set, _column_table_set>::value, "set() contains values from foreign tables");
*/
// Data // Data
using _data_t = update_list_data_t<Database, Assignments...>; using _data_t = update_list_data_t<Database, Assignments...>;
@ -95,13 +78,14 @@ namespace sqlpp
{ {
static_assert(_is_dynamic::value, "add must not be called for static from()"); static_assert(_is_dynamic::value, "add must not be called for static from()");
static_assert(is_assignment_t<Assignment>::value, "invalid assignment argument in add()"); static_assert(is_assignment_t<Assignment>::value, "invalid assignment argument in add()");
using _assigned_columns = detail::make_type_set_t<typename Assignments::_column_t...>;
static_assert(not detail::is_element_of<typename Assignment::_column_t, _assigned_columns>::value, "Must not assign value to column twice");
static_assert(sqlpp::detail::not_t<must_not_update_t, typename Assignment::_column_t>::value, "add() argument must not be updated"); static_assert(sqlpp::detail::not_t<must_not_update_t, typename Assignment::_column_t>::value, "add() argument must not be updated");
static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Assignment>::value, "assignment uses tables unknown to this statement in add()"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables<Assignment>::value, "assignment uses tables unknown to this statement in add()");
using ok = ::sqlpp::detail::all_t< using ok = ::sqlpp::detail::all_t<
_is_dynamic::value, _is_dynamic::value,
is_assignment_t<Assignment>::value, is_assignment_t<Assignment>::value>;
not must_not_update_t<typename Assignment::_column_t>::value>;
_add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert _add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert
} }
@ -185,19 +169,37 @@ namespace sqlpp
static void _check_consistency() {} static void _check_consistency() {}
template<typename... Args> template<typename... Assignments>
auto set(Args... args) auto set(Assignments... assignments)
-> _new_statement_t<update_list_t<void, Args...>> -> _new_statement_t<update_list_t<void, Assignments...>>
{ {
return { *static_cast<typename Policies::_statement_t*>(this), update_list_data_t<void, Args...>{args...} }; static_assert(sizeof...(Assignments), "at least one assignment expression required in set()");
return _set_impl<void>(assignments...);
} }
template<typename... Args> template<typename... Assignments>
auto dynamic_set(Args... args) auto dynamic_set(Assignments... assignments)
-> _new_statement_t<update_list_t<_database_t, Args...>> -> _new_statement_t<update_list_t<_database_t, Assignments...>>
{ {
static_assert(not std::is_same<_database_t, void>::value, "dynamic_set must not be called in a static statement"); static_assert(not std::is_same<_database_t, void>::value, "dynamic_set() must not be called in a static statement");
return { *static_cast<typename Policies::_statement_t*>(this), update_list_data_t<_database_t, Args...>{args...} }; return _set_impl<_database_t>(assignments...);
}
private:
template<typename Database, typename... Assignments>
auto _set_impl(Assignments... assignments)
-> _new_statement_t<update_list_t<Database, Assignments...>>
{
static_assert(not ::sqlpp::detail::has_duplicates<Assignments...>::value, "at least one duplicate argument detected in set()");
static_assert(::sqlpp::detail::all_t<is_assignment_t<Assignments>::value...>::value, "at least one argument is not an assignment in set()");
static_assert(::sqlpp::detail::none_t<must_not_update_t<typename Assignments::_column_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()");
using _column_table_set = typename ::sqlpp::detail::make_joined_set<required_tables_of<typename Assignments::_column_t>...>::type;
using _value_table_set = typename ::sqlpp::detail::make_joined_set<required_tables_of<typename Assignments::_value_t>...>::type;
static_assert(sizeof...(Assignments) ? (_column_table_set::size::value == 1) : true, "set() contains assignments for columns from more than one table");
static_assert(::sqlpp::detail::is_subset_of<_value_table_set, _column_table_set>::value, "set() contains values from foreign tables");
return { *static_cast<typename Policies::_statement_t*>(this), update_list_data_t<Database, Assignments...>{assignments...} };
} }
}; };
}; };

View File

@ -61,8 +61,7 @@ int main()
serialize(update(t).set(t.gamma = false).where(t.beta != "transparent"), printer).str(); serialize(update(t).set(t.gamma = false).where(t.beta != "transparent"), printer).str();
serialize(update(t).set(t.beta = "opaque").where(t.beta != t.beta), printer).str(); serialize(update(t).set(t.beta = "opaque").where(t.beta != t.beta), printer).str();
auto u = dynamic_update(db, t).dynamic_set(t.gamma = false).dynamic_where(); auto u = dynamic_update(db, t).dynamic_set(t.gamma = false).dynamic_where();
#warning: This should fail since gamma is set already u.assignments.add(t.beta = "cannot update gamma a second time");
u.assignments.add(t.gamma = false);
u.where.add(t.gamma != false); u.where.add(t.gamma != false);
printer.reset(); printer.reset();
std::cerr << serialize(u, printer).str() << std::endl; std::cerr << serialize(u, printer).str() << std::endl;