From 3fb6c6c246af83dc662bbf31c48d4ebb741aed88 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 2 Jun 2014 06:40:22 +0200 Subject: [PATCH] SelectTest compiles again --- include/sqlpp11/select.h | 1 + include/sqlpp11/vendor/group_by.h | 2 +- include/sqlpp11/vendor/limit.h | 6 +++++- include/sqlpp11/vendor/offset.h | 6 +++++- include/sqlpp11/vendor/order_by.h | 2 +- include/sqlpp11/vendor/select_flag_list.h | 2 +- include/sqlpp11/vendor/where.h | 4 ++-- tests/SelectTest.cpp | 6 ++---- 8 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 28f31c01..a111c3cb 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -62,6 +62,7 @@ namespace sqlpp template struct select_policies_t { +#warning need to check policies' signature, e.g. a _data_t in _member_t template using _database_t = Db; using _statement_t = select_t; diff --git a/include/sqlpp11/vendor/group_by.h b/include/sqlpp11/vendor/group_by.h index caadc8db..a3732a5b 100644 --- a/include/sqlpp11/vendor/group_by.h +++ b/include/sqlpp11/vendor/group_by.h @@ -73,7 +73,7 @@ namespace sqlpp static_assert(::sqlpp::detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); // Data - using _data_t = select_flag_list_data_t; + using _data_t = group_by_data_t; // Member implementation with data and methods template diff --git a/include/sqlpp11/vendor/limit.h b/include/sqlpp11/vendor/limit.h index 62310324..cd5884c4 100644 --- a/include/sqlpp11/vendor/limit.h +++ b/include/sqlpp11/vendor/limit.h @@ -75,6 +75,8 @@ namespace sqlpp template struct _member_t { + using _data_t = limit_data_t; + _impl_t limit; _impl_t& operator()() { return limit; } const _impl_t& operator()() const { return limit; } @@ -126,7 +128,7 @@ namespace sqlpp using _recursive_traits = make_recursive_traits<>; // Data - using _data_t = limit_data_t; + using _data_t = dynamic_limit_data_t; // Member implementation with data and methods template @@ -148,6 +150,8 @@ namespace sqlpp template struct _member_t { + using _data_t = dynamic_limit_data_t; + _impl_t limit; _impl_t& operator()() { return limit; } const _impl_t& operator()() const { return limit; } diff --git a/include/sqlpp11/vendor/offset.h b/include/sqlpp11/vendor/offset.h index fd42d846..9ace773f 100644 --- a/include/sqlpp11/vendor/offset.h +++ b/include/sqlpp11/vendor/offset.h @@ -75,6 +75,8 @@ namespace sqlpp template struct _member_t { + using _data_t = offset_data_t; + _impl_t offset; _impl_t& operator()() { return offset; } const _impl_t& operator()() const { return offset; } @@ -126,7 +128,7 @@ namespace sqlpp using _recursive_traits = make_recursive_traits<>; // Data - using _data_t = offset_data_t; + using _data_t = dynamic_offset_data_t; // Member implementation with data and methods template @@ -148,6 +150,8 @@ namespace sqlpp template struct _member_t { + using _data_t = dynamic_offset_data_t; + _impl_t offset; _impl_t& operator()() { return offset; } const _impl_t& operator()() const { return offset; } diff --git a/include/sqlpp11/vendor/order_by.h b/include/sqlpp11/vendor/order_by.h index cd9e89d6..37e84724 100644 --- a/include/sqlpp11/vendor/order_by.h +++ b/include/sqlpp11/vendor/order_by.h @@ -73,7 +73,7 @@ namespace sqlpp static_assert(::sqlpp::detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); // Data - using _data_t = select_flag_list_data_t; + using _data_t = order_by_data_t; // Member implementation with data and methods template diff --git a/include/sqlpp11/vendor/select_flag_list.h b/include/sqlpp11/vendor/select_flag_list.h index 735e29e8..c458ad6e 100644 --- a/include/sqlpp11/vendor/select_flag_list.h +++ b/include/sqlpp11/vendor/select_flag_list.h @@ -98,7 +98,7 @@ namespace sqlpp template void _add_impl(Flag flag, const std::true_type&) { - return static_cast(this)->_select_flag_list()._dynamic_flags.emplace_back(flag); + return _data._dynamic_flags.emplace_back(flag); } template diff --git a/include/sqlpp11/vendor/where.h b/include/sqlpp11/vendor/where.h index b865a38e..0dcbd9c2 100644 --- a/include/sqlpp11/vendor/where.h +++ b/include/sqlpp11/vendor/where.h @@ -77,8 +77,6 @@ namespace sqlpp template struct _impl_t { - using _data_t = where_data_t; - template void add_ntc(Expression expression) { @@ -115,6 +113,8 @@ namespace sqlpp template struct _member_t { + using _data_t = where_data_t; + _impl_t where; _impl_t& operator()() { return where; } const _impl_t& operator()() const { return where; } diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index efa7e67a..e00312fc 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -55,7 +55,6 @@ int main() int64_t a = row.alpha; const std::string b = row.beta; } -#if 0 for (const auto& row : db(select(all_of(t).as(t)).from(t).where(true))) { @@ -70,7 +69,8 @@ int main() const bool g = row.gamma; } - auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where()/*.dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset()*/; + auto stat = sqlpp::select().columns(all_of(t)).flags(sqlpp::all).from(t).extra_tables(f,t).where(t.alpha > 0).group_by(t.alpha).order_by(t.gamma.asc()).having(t.gamma).limit(7).offset(19); + auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where().dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset(); s.select_flags.add(sqlpp::distinct); s.selected_columns.add(f.omega); s.from.add(f); @@ -85,9 +85,7 @@ int main() int64_t a = row.alpha; } - auto X = select(all_of(t)).from(t).as(t.alpha); -#endif return 0; }