From 23d0bc91a162e6243953fce35716bbb03a882db4 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 27 Oct 2014 07:31:37 +0100 Subject: [PATCH 001/105] Make result methods templates of their statement, not their statement's policies --- include/sqlpp11/insert.h | 4 ++-- include/sqlpp11/noop.h | 2 +- include/sqlpp11/remove.h | 4 ++-- include/sqlpp11/select_column_list.h | 6 +++--- include/sqlpp11/statement.h | 18 ++++++++++++------ include/sqlpp11/update.h | 4 ++-- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index d6e1bc3a..4a24dcb3 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -46,10 +46,10 @@ namespace sqlpp using _traits = make_traits; struct _name_t {}; - template + template struct _result_methods_t { - using _statement_t = derived_statement_t; + using _statement_t = Statement; const _statement_t& _get_statement() const { diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index 5d6afae2..a28fcc95 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -40,7 +40,7 @@ namespace sqlpp struct _name_t {}; - template + template struct _result_methods_t {}; }; diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index c607b847..f6ab9445 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -46,10 +46,10 @@ namespace sqlpp using _traits = make_traits; struct _name_t {}; - template + template struct _result_methods_t { - using _statement_t = derived_statement_t; + using _statement_t = Statement; const _statement_t& _get_statement() const { diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 0b77b021..abfe6860 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -235,10 +235,10 @@ namespace sqlpp }; // Result methods - template + template struct _result_methods_t { - using _statement_t = derived_statement_t; + using _statement_t = Statement; const _statement_t& _get_statement() const { @@ -277,7 +277,7 @@ namespace sqlpp template _alias_t as(const AliasProvider& aliasProvider) const { - static_assert(Policies::_can_be_used_as_table::value, "statement cannot be used as table, e.g. due to missing tables"); + static_assert(_statement_t::_can_be_used_as_table(), "statement cannot be used as table, e.g. due to missing tables"); static_assert(detail::none_t::value...>::value, "cannot use multi-columns in sub selects"); return _table_t(_get_statement()).as(aliasProvider); } diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 0ba602f6..4092638d 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -79,18 +79,19 @@ namespace sqlpp using _result_type_provider = detail::get_last_if; - struct _result_methods_t: public _result_type_provider::template _result_methods_t + struct _result_methods_t: public _result_type_provider::template _result_methods_t<_statement_t> {}; // A select can be used as a pseudo table if // - at least one column is selected // - the select is complete (leaks no tables) - using _can_be_used_as_table = typename std::conditional< - is_select_column_list_t<_result_type_provider>::value and _required_tables::size::value == 0, - std::true_type, - std::false_type - >::type; + static constexpr bool _can_be_used_as_table() + { + return is_select_column_list_t<_result_type_provider>::value and _required_tables::size::value == 0 + ? true + : false; + } using _value_type = typename std::conditional< detail::none_t::value...>::value, @@ -173,6 +174,11 @@ namespace sqlpp return _get_static_no_of_parameters(); } + static constexpr bool _can_be_used_as_table() + { + return _policies_t::_can_be_used_as_table(); + } + static void _check_consistency() { static_assert(not required_tables_of<_policies_t>::size::value, "one sub expression requires tables which are otherwise not known in the statement"); diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index 492f0791..2abf12f6 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -46,10 +46,10 @@ namespace sqlpp using _traits = make_traits; struct _name_t {}; - template + template struct _result_methods_t { - using _statement_t = derived_statement_t; + using _statement_t = Statement; const _statement_t& _get_statement() const { From 69337fd7ca1faa322bc94e5deafc1240fee9755d Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 27 Oct 2014 17:36:33 +0100 Subject: [PATCH 002/105] Added first draft of custom query --- include/sqlpp11/custom_query.h | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 include/sqlpp11/custom_query.h diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h new file mode 100644 index 00000000..4af3cf71 --- /dev/null +++ b/include/sqlpp11/custom_query.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_CUSTOM_QUERY_H +#define SQLPP_CUSTOM_QUERY_H + +#include + +namespace sqlpp +{ + template + struct custom_query_t: + public FirstPart::_result_type_provider::template _result_methods_t + { + custom_query_t(Expressions... expressions): + _expressions(expressions...) + {} + + custom_query_t(const custom_query_t&) = default; + custom_query_t(custom_query_t&&) = default; + custom_query_t& operator=(const custom_query_t&) = default; + custom_query_t& operator=(custom_query_t&&) = default; + ~custom_query_t() = default; + + std::tuple _parts; + }; + + template + struct serializer_t> + { + using T = custom_query_t; + + static Context& _(const T& t, Context& context) + { + interpret_tuple(t._parts, " ", context); + return context; + } + }; + + template + auto custom_query(Parts... parts) + -> statement_t + { + return statement_t(parts...); + } + + template + auto dynamic_custom_query(const Database&, Parts...) + -> statement_t + { + static_assert(std::is_base_of::value, "Invalid database parameter"); + return { }; + } +} +#endif From 6684ac9ea830cc592f595795b763f806478806fb Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 29 Oct 2014 07:34:42 +0100 Subject: [PATCH 003/105] Added first test --- include/sqlpp11/custom_query.h | 20 +++++++------- include/sqlpp11/interpret_tuple.h | 23 ++++++++++------ tests/CMakeLists.txt | 23 ++++++++-------- tests/CustomQueryTest.cpp | 44 +++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 29 deletions(-) create mode 100644 tests/CustomQueryTest.cpp diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 4af3cf71..4acf12d1 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -31,12 +31,12 @@ namespace sqlpp { - template - struct custom_query_t: - public FirstPart::_result_type_provider::template _result_methods_t + template + struct custom_query_t/*: + public FirstPart::_result_type_provider::template _result_methods_t*/ { - custom_query_t(Expressions... expressions): - _expressions(expressions...) + custom_query_t(Parts... parts): + _parts(parts...) {} custom_query_t(const custom_query_t&) = default; @@ -45,7 +45,7 @@ namespace sqlpp custom_query_t& operator=(custom_query_t&&) = default; ~custom_query_t() = default; - std::tuple _parts; + std::tuple _parts; }; template @@ -55,21 +55,21 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - interpret_tuple(t._parts, " ", context); + interpret_tuple_without_braces(t._parts, " ", context); return context; } }; template auto custom_query(Parts... parts) - -> statement_t + -> custom_query_t { - return statement_t(parts...); + return custom_query_t(parts...); } template auto dynamic_custom_query(const Database&, Parts...) - -> statement_t + -> custom_query_t { static_assert(std::is_base_of::value, "Invalid database parameter"); return { }; diff --git a/include/sqlpp11/interpret_tuple.h b/include/sqlpp11/interpret_tuple.h index 4edb2631..518c607c 100644 --- a/include/sqlpp11/interpret_tuple.h +++ b/include/sqlpp11/interpret_tuple.h @@ -34,20 +34,20 @@ namespace sqlpp { - template - static void interpret_tuple_element(const Element& element, const Separator& separator, Context& context, size_t index) + template + static void interpret_tuple_element(const Element& element, const Separator& separator, Context& context, const UseBraces&, size_t index) { if (index) context << separator; - if (requires_braces_t::value) + if (UseBraces::value and requires_braces_t::value) context << "("; serialize(element, context); - if (requires_braces_t::value) + if (UseBraces::value and requires_braces_t::value) context << ")"; } - template - auto interpret_tuple_impl(const Tuple& t, const Separator& separator, Context& context, const detail::index_sequence&) + template + auto interpret_tuple_impl(const Tuple& t, const Separator& separator, Context& context, const UseBraces& useBraces, const detail::index_sequence&) -> Context& { // Note: A braced-init-list does guarantee the order of evaluation according to 12.6.1 [class.explicit.init] paragraph 2 and 8.5.4 [dcl.init.list] paragraph 4. @@ -55,7 +55,7 @@ namespace sqlpp // See also: "http://stackoverflow.com/questions/6245735/pretty-print-stdtuple/6245777#6245777" // Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could be used using swallow = int[]; - (void) swallow{(interpret_tuple_element(std::get(t), separator, context, Is), 0)...}; + (void) swallow{(interpret_tuple_element(std::get(t), separator, context, useBraces, Is), 0)...}; return context; } @@ -63,7 +63,14 @@ namespace sqlpp auto interpret_tuple(const Tuple& t, const Separator& separator, Context& context) -> Context& { - return interpret_tuple_impl(t, separator, context, detail::make_index_sequence::value>{}); + return interpret_tuple_impl(t, separator, context, std::true_type{}, detail::make_index_sequence::value>{}); + } + + template + auto interpret_tuple_without_braces(const Tuple& t, const Separator& separator, Context& context) + -> Context& + { + return interpret_tuple_impl(t, separator, context, std::false_type{}, detail::make_index_sequence::value>{}); } } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 86462e61..b521ce6b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,17 +6,18 @@ macro (build_and_run arg) add_test("${arg}" "${arg}") endmacro () -build_and_run(BooleanExpressionTest) -build_and_run(InterpretTest) -build_and_run(InsertTest) -build_and_run(RemoveTest) -build_and_run(UpdateTest) -build_and_run(SelectTest) -build_and_run(SelectTypeTest) -build_and_run(FunctionTest) -build_and_run(PreparedTest) -build_and_run(Minimalistic) -build_and_run(ResultTest) +#build_and_run(BooleanExpressionTest) +build_and_run(CustomQueryTest) +#build_and_run(InterpretTest) +#build_and_run(InsertTest) +#build_and_run(RemoveTest) +#build_and_run(UpdateTest) +#build_and_run(SelectTest) +#build_and_run(SelectTypeTest) +#build_and_run(FunctionTest) +#build_and_run(PreparedTest) +#build_and_run(Minimalistic) +#build_and_run(ResultTest) # if you want to use the generator, you can do something like this: #find_package(PythonInterp REQUIRED) diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp new file mode 100644 index 00000000..64654367 --- /dev/null +++ b/tests/CustomQueryTest.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "Sample.h" +#include "MockDb.h" +#include +#include + +MockDb db = {}; +MockDb::_serializer_context_t printer; + +int main() +{ + test::TabFoo f; + test::TabBar t; + + auto c = custom_query(select(all_of(t)).from(t), insert_into(t)); + std::cerr << serialize(c, printer).str() << std::endl; + + return 0; +} From 514ed4139cc229db4664f2e15fad20df0bcdbe66 Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 31 Oct 2014 08:28:51 +0100 Subject: [PATCH 004/105] First custom query sent to MockDb --- include/sqlpp11/custom_query.h | 50 ++++++++++++++++++++++------ include/sqlpp11/select_column_list.h | 10 +++--- include/sqlpp11/statement.h | 6 ++-- tests/CustomQueryTest.cpp | 5 +-- 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 4acf12d1..e2492eee 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -28,22 +28,48 @@ #define SQLPP_CUSTOM_QUERY_H #include +#include +#include namespace sqlpp { template - struct custom_query_t/*: - public FirstPart::_result_type_provider::template _result_methods_t*/ - { - custom_query_t(Parts... parts): - _parts(parts...) - {} + struct custom_query_t; - custom_query_t(const custom_query_t&) = default; - custom_query_t(custom_query_t&&) = default; - custom_query_t& operator=(const custom_query_t&) = default; - custom_query_t& operator=(custom_query_t&&) = default; - ~custom_query_t() = default; + namespace detail + { + template + struct custom_parts_t + { + using _custom_query_t = custom_query_t; + using _result_type_provider = detail::get_first_if; + using _result_methods_t = typename _result_type_provider::template _result_methods_t<_result_type_provider>; + }; + } + + template + struct custom_query_t: + private detail::custom_parts_t::_result_methods_t + { + using _methods_t = typename detail::custom_parts_t::_result_methods_t; + + static void _check_consistency() {}; + + template + auto _run(Db& db) const -> decltype(_methods_t::_run(db, *this)) + { + return _methods_t::_run(db, *this); + } + + custom_query_t(Parts... parts): + _parts(parts...) + {} + + custom_query_t(const custom_query_t&) = default; + custom_query_t(custom_query_t&&) = default; + custom_query_t& operator=(const custom_query_t&) = default; + custom_query_t& operator=(custom_query_t&&) = default; + ~custom_query_t() = default; std::tuple _parts; }; @@ -64,6 +90,7 @@ namespace sqlpp auto custom_query(Parts... parts) -> custom_query_t { + static_assert(sizeof...(Parts) > 0, "custom query requires at least one argument"); return custom_query_t(parts...); } @@ -71,6 +98,7 @@ namespace sqlpp auto dynamic_custom_query(const Database&, Parts...) -> custom_query_t { + static_assert(sizeof...(Parts) > 0, "custom query requires at least one query argument"); static_assert(std::is_base_of::value, "Invalid database parameter"); return { }; } diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index abfe6860..8af3d38a 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -293,14 +293,14 @@ namespace sqlpp } // Execute - template - auto _run(Db& db) const - -> result_t_get_statement())), _result_row_t> + template + auto _run(Db& db, const S& s) const + -> result_t> { - _statement_t::_check_consistency(); + S::_check_consistency(); static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead"); - return {db.select(_get_statement()), get_dynamic_names()}; + return {db.select(s), get_dynamic_names()}; } // Prepare diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 4092638d..e0d48437 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -132,17 +132,19 @@ namespace sqlpp public Policies::template _methods_t>... { using _policies_t = typename detail::statement_policies_t; + using _result_type_provider = typename _policies_t::_result_type_provider; + template + using _result_methods_t = typename _result_type_provider::template _result_methods_t; using _traits = make_traits, tag::is_select, tag_if::value>, tag_if::value>, + tag_if::value>::value>, tag::requires_braces>; using _recursive_traits = typename _policies_t::_recursive_traits; using _used_outer_tables = typename _policies_t::_all_provided_outer_tables; - using _result_type_provider = typename _policies_t::_result_type_provider; - using _name_t = typename _result_type_provider::_name_t; // Constructors diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index 64654367..67347e3d 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -37,8 +37,9 @@ int main() test::TabFoo f; test::TabBar t; - auto c = custom_query(select(all_of(t)).from(t), insert_into(t)); - std::cerr << serialize(c, printer).str() << std::endl; + auto c = custom_query(select(all_of(t)).from(t)); + //std::cerr << serialize(c, printer).str() << std::endl; + db(c); return 0; } From e79585b1659704dc473b2bcce259d27ae1b3259d Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 3 Nov 2014 17:52:02 +0100 Subject: [PATCH 005/105] Can compile (very simple) custom queries and selects --- include/sqlpp11/custom_query.h | 8 +++++++ include/sqlpp11/insert.h | 35 ++++++++++++++++++++++------ include/sqlpp11/prepared_select.h | 8 +++---- include/sqlpp11/remove.h | 35 ++++++++++++++++++++++------ include/sqlpp11/select_column_list.h | 29 +++++++++++++++++++---- include/sqlpp11/update.h | 35 ++++++++++++++++++++++------ tests/CMakeLists.txt | 2 +- tests/CustomQueryTest.cpp | 3 ++- 8 files changed, 123 insertions(+), 32 deletions(-) diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index e2492eee..c5d320e0 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -52,6 +52,8 @@ namespace sqlpp private detail::custom_parts_t::_result_methods_t { using _methods_t = typename detail::custom_parts_t::_result_methods_t; + using _traits = make_traits; + using _recursive_traits = make_recursive_traits; static void _check_consistency() {}; @@ -61,6 +63,12 @@ namespace sqlpp return _methods_t::_run(db, *this); } + template + auto _prepare(Db& db) const -> decltype(_methods_t::_prepare(db, *this)) + { + return _methods_t::_prepare(db, *this); + } + custom_query_t(Parts... parts): _parts(parts...) {} diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 4a24dcb3..0895604c 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -56,6 +56,17 @@ namespace sqlpp return static_cast(*this); } + // Execute + template + auto _run(Db& db, const Composite& composite) const + -> decltype(db.insert(composite)) + { + Composite::_check_consistency(); + static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); + + return db.insert(composite); + } + template auto _run(Db& db) const -> decltype(db.insert(this->_get_statement())) { @@ -65,14 +76,24 @@ namespace sqlpp return db.insert(_get_statement()); } - template - auto _prepare(Db& db) const - -> prepared_insert_t - { - _statement_t::_check_consistency(); + // Prepare + template + auto _prepare(Db& db, const Composite& composite) const + -> prepared_insert_t + { + Composite::_check_consistency(); - return {{}, db.prepare_insert(_get_statement())}; - } + return {{}, db.prepare_insert(composite)}; + } + + template + auto _prepare(Db& db) const + -> prepared_insert_t + { + _statement_t::_check_consistency(); + + return {{}, db.prepare_insert(_get_statement())}; + } }; }; diff --git a/include/sqlpp11/prepared_select.h b/include/sqlpp11/prepared_select.h index 2c74e9a2..2701e17e 100644 --- a/include/sqlpp11/prepared_select.h +++ b/include/sqlpp11/prepared_select.h @@ -32,12 +32,12 @@ namespace sqlpp { - template + template struct prepared_select_t { - using _result_row_t = typename Select::template _result_row_t; - using _parameter_list_t = make_parameter_list_t::template _result_row_t; using IndexSequence = ResultRow::_field_index_sequence; static_assert(std::is_same>::value, "invalid field sequence"); } From ed7f1f1a93dbae329a676696a537d8c302c5af41 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 4 Nov 2014 07:56:26 +0100 Subject: [PATCH 007/105] Added missing file --- include/sqlpp11/detail/get_first.h | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 include/sqlpp11/detail/get_first.h diff --git a/include/sqlpp11/detail/get_first.h b/include/sqlpp11/detail/get_first.h new file mode 100644 index 00000000..25a784d8 --- /dev/null +++ b/include/sqlpp11/detail/get_first.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_DETAIL_GET_FIRST_H +#define SQLPP_DETAIL_GET_FIRST_H + +#include + +namespace sqlpp +{ + namespace detail + { + template class Predicate, typename Default, typename... T> + struct get_first_if_impl; + + template class Predicate, typename Default> + struct get_first_if_impl + { + using type = Default; + }; + + template class Predicate, typename Default, typename T, typename... Rest> + struct get_first_if_impl + { + using rest = typename get_first_if_impl::type; + using type = typename std::conditional::value, + T, + rest>::type; + }; + + template class Predicate, typename Default, typename... T> + using get_first_if = typename get_first_if_impl::type; + } +} + + +#endif From 60042c2dd3b1b2817b5394aaa0ee4807fd675cf8 Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 5 Nov 2014 07:27:19 +0100 Subject: [PATCH 008/105] Added run and prepare to noop, allowing void custom queries --- include/sqlpp11/custom_query.h | 11 +++--- include/sqlpp11/noop.h | 48 ++++++++++++++++++++++++- include/sqlpp11/prepared_execute.h | 58 ++++++++++++++++++++++++++++++ include/sqlpp11/verbatim.h | 6 ++++ tests/CustomQueryTest.cpp | 7 +++- 5 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 include/sqlpp11/prepared_execute.h diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index c5d320e0..f2d8eac3 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -96,19 +96,20 @@ namespace sqlpp template auto custom_query(Parts... parts) - -> custom_query_t + -> custom_query_t...> { static_assert(sizeof...(Parts) > 0, "custom query requires at least one argument"); - return custom_query_t(parts...); + return custom_query_t...>(parts...); } template - auto dynamic_custom_query(const Database&, Parts...) - -> custom_query_t + auto dynamic_custom_query(const Database&, Parts... parts) + -> custom_query_t...> { static_assert(sizeof...(Parts) > 0, "custom query requires at least one query argument"); static_assert(std::is_base_of::value, "Invalid database parameter"); - return { }; + + return custom_query_t...>(parts...); } } #endif diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index a28fcc95..e0b7a275 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace sqlpp { @@ -42,7 +43,52 @@ namespace sqlpp template struct _result_methods_t - {}; + { + using _statement_t = Statement; + + const _statement_t& _get_statement() const + { + return static_cast(*this); + } + + // Execute + template + auto _run(Db& db, const Composite& composite) const -> void + { + Composite::_check_consistency(); + static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead"); + + return db.execute(composite); + } + + template + auto _run(Db& db) const -> void + { + _statement_t::_check_consistency(); + + static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); + return db.execute(_get_statement()); + } + + // Prepare + template + auto _prepare(Db& db, const Composite& composite) const + -> prepared_execute_t + { + Composite::_check_consistency(); + + return {{}, db.prepare_execute(composite)}; + } + + template + auto _prepare(Db& db) const + -> prepared_execute_t + { + _statement_t::_check_consistency(); + + return {{}, db.prepare_execute(_get_statement())}; + } + }; }; template diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h new file mode 100644 index 00000000..a72577ad --- /dev/null +++ b/include/sqlpp11/prepared_execute.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_PREPARED_EXECUTE_H +#define SQLPP_PREPARED_EXECUTE_H + +#include +#include + +namespace sqlpp +{ + template + struct prepared_execute_t + { + using _parameter_list_t = make_parameter_list_t; + using _prepared_statement_t = typename Db::_prepared_statement_t; + + auto _run(Db& db) const + -> size_t + { + return db.run_prepared_execute(*this); + } + + void _bind_params() const + { + params._bind(_prepared_statement); + } + + _parameter_list_t params; + mutable _prepared_statement_t _prepared_statement; + }; + +} + +#endif diff --git a/include/sqlpp11/verbatim.h b/include/sqlpp11/verbatim.h index d1b43006..d03ea4af 100644 --- a/include/sqlpp11/verbatim.h +++ b/include/sqlpp11/verbatim.h @@ -27,6 +27,7 @@ #ifndef SQLPP_VERBATIM_H #define SQLPP_VERBATIM_H +#include #include #include @@ -71,6 +72,11 @@ namespace sqlpp return { s }; } + auto verbatim(std::string s) -> verbatim_t + { + return { s }; + } + } #endif diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index ae2b11e2..1be8062c 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -37,10 +37,15 @@ int main() test::TabFoo f; test::TabBar t; - auto c = custom_query(select(all_of(t)).from(t)); + auto c = custom_query(select(all_of(t)).from(t), sqlpp::verbatim("INTO"), t); + std::cerr << serialize(c, printer).str() << std::endl; db(c); auto p = db.prepare(custom_query(select(all_of(t)).from(t).where(t.alpha > sqlpp::parameter(t.alpha)))); + printer.reset(); + auto x = custom_query(sqlpp::verbatim("PRAGMA writeable_schema") == true); + std::cerr << serialize(x, printer).str() << std::endl; + return 0; } From be3292b6ce4a86385043e81f67a04ad565c0f24c Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 5 Nov 2014 17:50:46 +0100 Subject: [PATCH 009/105] Fixed parameter determination and added execution of void statements --- include/sqlpp11/custom_query.h | 26 ++++++++++++++++++-------- include/sqlpp11/insert.h | 2 +- include/sqlpp11/noop.h | 2 +- include/sqlpp11/remove.h | 2 +- include/sqlpp11/select_column_list.h | 2 +- include/sqlpp11/update.h | 2 +- tests/CustomQueryTest.cpp | 4 ++++ tests/MockDb.h | 17 +++++++++++++++++ 8 files changed, 44 insertions(+), 13 deletions(-) diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index f2d8eac3..61a3b459 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -55,6 +55,16 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; + custom_query_t(Parts... parts): + _parts(parts...) + {} + + custom_query_t(const custom_query_t&) = default; + custom_query_t(custom_query_t&&) = default; + custom_query_t& operator=(const custom_query_t&) = default; + custom_query_t& operator=(custom_query_t&&) = default; + ~custom_query_t() = default; + static void _check_consistency() {}; template @@ -69,15 +79,15 @@ namespace sqlpp return _methods_t::_prepare(db, *this); } - custom_query_t(Parts... parts): - _parts(parts...) - {} + static constexpr size_t _get_static_no_of_parameters() + { + return std::tuple_size>::value; + } - custom_query_t(const custom_query_t&) = default; - custom_query_t(custom_query_t&&) = default; - custom_query_t& operator=(const custom_query_t&) = default; - custom_query_t& operator=(custom_query_t&&) = default; - ~custom_query_t() = default; + size_t _get_no_of_parameters() const + { + return _get_static_no_of_parameters(); + } std::tuple _parts; }; diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 0895604c..59091a04 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -62,7 +62,7 @@ namespace sqlpp -> decltype(db.insert(composite)) { Composite::_check_consistency(); - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); + static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); return db.insert(composite); } diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index e0b7a275..1c1b4d61 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -56,7 +56,7 @@ namespace sqlpp auto _run(Db& db, const Composite& composite) const -> void { Composite::_check_consistency(); - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead"); + static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead"); return db.execute(composite); } diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index fce6c8a7..00890eaf 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -62,7 +62,7 @@ namespace sqlpp -> decltype(db.remove(composite)) { Composite::_check_consistency(); - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run remove directly with parameters, use prepare instead"); + static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run remove directly with parameters, use prepare instead"); return db.remove(composite); } diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 4606f477..0a6fa6bf 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -298,7 +298,7 @@ namespace sqlpp -> result_t> { Composite::_check_consistency(); - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead"); + static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead"); return {db.select(composite), get_dynamic_names()}; } diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index 18765c59..f940fdab 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -62,7 +62,7 @@ namespace sqlpp -> decltype(db.update(composite)) { Composite::_check_consistency(); - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run update directly with parameters, use prepare instead"); + static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run update directly with parameters, use prepare instead"); return db.update(composite); } diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index 1be8062c..9ac36614 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -42,10 +42,14 @@ int main() db(c); auto p = db.prepare(custom_query(select(all_of(t)).from(t).where(t.alpha > sqlpp::parameter(t.alpha)))); + p.params.alpha = 8; printer.reset(); auto x = custom_query(sqlpp::verbatim("PRAGMA writeable_schema") == true); std::cerr << serialize(x, printer).str() << std::endl; + db(x); + + db.prepare(x); return 0; } diff --git a/tests/MockDb.h b/tests/MockDb.h index 0586c04c..33a1d7e2 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -112,6 +112,15 @@ struct MockDbT: public sqlpp::connection return t._run(*this); } + void execute(const std::string& command); + + template + void execute(const Statement& x) + { + _serializer_context_t context; + ::sqlpp::serialize(x, context); + } + template size_t insert(const Insert& x) { @@ -154,6 +163,14 @@ struct MockDbT: public sqlpp::connection } + template + _prepared_statement_t prepare_execute(Statement& x) + { + _serializer_context_t context; + ::sqlpp::serialize(x, context); + return nullptr; + } + template _prepared_statement_t prepare_insert(Insert& x) { From 55ed36ff33e20bf41064d6454a29fda4c704f735 Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 7 Nov 2014 09:34:48 +0100 Subject: [PATCH 010/105] Added prepared_execute to MockDb --- tests/CustomQueryTest.cpp | 6 +++--- tests/MockDb.h | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index 9ac36614..b7a3d483 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -37,7 +37,7 @@ int main() test::TabFoo f; test::TabBar t; - auto c = custom_query(select(all_of(t)).from(t), sqlpp::verbatim("INTO"), t); + auto c = custom_query(select(all_of(t)).from(t), sqlpp::verbatim("INTO"), f); std::cerr << serialize(c, printer).str() << std::endl; db(c); @@ -45,11 +45,11 @@ int main() p.params.alpha = 8; printer.reset(); - auto x = custom_query(sqlpp::verbatim("PRAGMA writeable_schema") == true); + auto x = custom_query(sqlpp::verbatim("PRAGMA writeable_schema = "), true); std::cerr << serialize(x, printer).str() << std::endl; db(x); - db.prepare(x); + db.run_prepared_execute(db.prepare(x)); return 0; } diff --git a/tests/MockDb.h b/tests/MockDb.h index 33a1d7e2..85bf5630 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -114,7 +114,8 @@ struct MockDbT: public sqlpp::connection void execute(const std::string& command); - template + template::value, void>::type> void execute(const Statement& x) { _serializer_context_t context; @@ -179,6 +180,11 @@ struct MockDbT: public sqlpp::connection return nullptr; } + template + void run_prepared_execute(const PreparedExecute& x) + { + } + template size_t run_prepared_insert(const PreparedInsert& x) { From ba1f200ef13ad25c4aac207936f9150c77de7216 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 8 Nov 2014 15:21:11 +0100 Subject: [PATCH 011/105] Added free function where() --- include/sqlpp11/where.h | 6 ++++++ tests/CustomQueryTest.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 7fb09551..01384545 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -27,6 +27,7 @@ #ifndef SQLPP_WHERE_H #define SQLPP_WHERE_H +#include #include #include #include @@ -278,6 +279,11 @@ namespace sqlpp } }; + template + auto where(T&&... t) -> decltype(statement_t>().where(std::forward(t)...)) + { + return statement_t>().where(std::forward(t)...); + } } #endif diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index b7a3d483..61b358e5 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -41,7 +41,7 @@ int main() std::cerr << serialize(c, printer).str() << std::endl; db(c); - auto p = db.prepare(custom_query(select(all_of(t)).from(t).where(t.alpha > sqlpp::parameter(t.alpha)))); + auto p = db.prepare(custom_query(select(all_of(t)).from(t), where(t.alpha > sqlpp::parameter(t.alpha)))); p.params.alpha = 8; printer.reset(); From 548a60102689abaf8786f746d2a11f2f15d20985 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 9 Nov 2014 13:00:17 +0100 Subject: [PATCH 012/105] Added into() free function --- include/sqlpp11/into.h | 6 ++++++ tests/CustomQueryTest.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index cff8fb35..e1d2ddd5 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -27,6 +27,7 @@ #ifndef SQLPP_INTO_H #define SQLPP_INTO_H +#include #include #include #include @@ -168,6 +169,11 @@ namespace sqlpp } }; + template + auto into(T&&... t) -> decltype(statement_t().into(std::forward(t)...)) + { + return statement_t().into(std::forward(t)...); + } } #endif diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index 61b358e5..b5635f37 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -37,7 +37,7 @@ int main() test::TabFoo f; test::TabBar t; - auto c = custom_query(select(all_of(t)).from(t), sqlpp::verbatim("INTO"), f); + auto c = custom_query(select(all_of(t)).from(t), into(f)); std::cerr << serialize(c, printer).str() << std::endl; db(c); From f6b223138b07734631838f9b53b294d76cd8c2b5 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 9 Nov 2014 16:26:36 +0100 Subject: [PATCH 013/105] Added method to set return type of custom query --- include/sqlpp11/custom_query.h | 12 ++++++ include/sqlpp11/hidden.h | 65 ++++++++++++++++++++++++++++++ include/sqlpp11/prepared_execute.h | 2 +- tests/CustomQueryTest.cpp | 28 +++++++++---- 4 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 include/sqlpp11/hidden.h diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 61a3b459..662891dd 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -29,6 +29,7 @@ #include #include +#include #include namespace sqlpp @@ -59,6 +60,10 @@ namespace sqlpp _parts(parts...) {} + custom_query_t(std::tuple parts): + _parts(parts) + {} + custom_query_t(const custom_query_t&) = default; custom_query_t(custom_query_t&&) = default; custom_query_t& operator=(const custom_query_t&) = default; @@ -89,6 +94,13 @@ namespace sqlpp return _get_static_no_of_parameters(); } + template + auto with_result_type_of(Part part) + -> custom_query_t + { + return {tuple_cat(std::make_tuple(part), _parts)}; + } + std::tuple _parts; }; diff --git a/include/sqlpp11/hidden.h b/include/sqlpp11/hidden.h new file mode 100644 index 00000000..e9f98cfa --- /dev/null +++ b/include/sqlpp11/hidden.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_HIDDEN_H +#define SQLPP_HIDDEN_H + +namespace sqlpp +{ + template + struct hidden_t: + public Part + { + hidden_t(Part part): + Part(part) + {} + + hidden_t(const hidden_t&) = default; + hidden_t(hidden_t&&) = default; + hidden_t& operator=(const hidden_t&) = default; + hidden_t& operator=(hidden_t&&) = default; + ~hidden_t() = default; + }; + + template + struct serializer_t> + { + using T = hidden_t; + + static Context& _(const T& t, Context& context) + { + return context; + } + }; + + template + auto hidden(Part part) + -> hidden_t + { + return {part}; + } +} +#endif diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h index a72577ad..e181d37c 100644 --- a/include/sqlpp11/prepared_execute.h +++ b/include/sqlpp11/prepared_execute.h @@ -39,7 +39,7 @@ namespace sqlpp using _prepared_statement_t = typename Db::_prepared_statement_t; auto _run(Db& db) const - -> size_t + -> void { return db.run_prepared_execute(*this); } diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index b5635f37..96870380 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -37,19 +37,31 @@ int main() test::TabFoo f; test::TabBar t; - auto c = custom_query(select(all_of(t)).from(t), into(f)); - std::cerr << serialize(c, printer).str() << std::endl; - db(c); - - auto p = db.prepare(custom_query(select(all_of(t)).from(t), where(t.alpha > sqlpp::parameter(t.alpha)))); - p.params.alpha = 8; - + // A void custom query printer.reset(); auto x = custom_query(sqlpp::verbatim("PRAGMA writeable_schema = "), true); std::cerr << serialize(x, printer).str() << std::endl; db(x); - db.run_prepared_execute(db.prepare(x)); + // Syntactically, it is possible to use this void query as a prepared statement, too, not sure, whether this makes sense very often... + db(db.prepare(x)); + + // A prepared custom select + // The return type of the custom query is determined from the first argument which does have a return type, in this case the select + auto p = db.prepare(custom_query(select(all_of(t)).from(t), where(t.alpha > sqlpp::parameter(t.alpha)))); + p.params.alpha = 8; + for (const auto& row : db(p)) + { + std::cerr << row.alpha << std::endl; + } + + // A custom (select ... into) with adjusted return type + // The first argument with a return type is the select, but the custom query is really an insert. Thus, we tell it so. + printer.reset(); + auto c = custom_query(select(all_of(t)).from(t), into(f)).with_result_type_of(insert_into(f)); + std::cerr << serialize(c, printer).str() << std::endl; + auto i = db(c); + static_assert(std::is_integral::value, "insert yields an integral value"); return 0; } From a20ff91c2d459cea4678b4ed1f143eff99ff0483 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 9 Nov 2014 16:34:48 +0100 Subject: [PATCH 014/105] Added missing file --- include/sqlpp11/statement_fwd.h | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/sqlpp11/statement_fwd.h diff --git a/include/sqlpp11/statement_fwd.h b/include/sqlpp11/statement_fwd.h new file mode 100644 index 00000000..90d33379 --- /dev/null +++ b/include/sqlpp11/statement_fwd.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_STATEMENT_FWD_H +#define SQLPP_STATEMENT_FWD_H + +namespace sqlpp +{ + template + struct statement_t; +} + +#endif From 02acab8e344dd34bb691100f01587bf5943b1d1a Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 9 Nov 2014 17:03:32 +0100 Subject: [PATCH 015/105] Fixed compilation for g++-4.8 --- include/sqlpp11/custom_query.h | 4 ++-- include/sqlpp11/select_column_list.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 662891dd..9c77bc72 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -73,13 +73,13 @@ namespace sqlpp static void _check_consistency() {}; template - auto _run(Db& db) const -> decltype(_methods_t::_run(db, *this)) + auto _run(Db& db) const -> decltype(std::declval<_methods_t>()._run(db, *this)) { return _methods_t::_run(db, *this); } template - auto _prepare(Db& db) const -> decltype(_methods_t::_prepare(db, *this)) + auto _prepare(Db& db) const -> decltype(std::declval<_methods_t>()._prepare(db, *this)) { return _methods_t::_prepare(db, *this); } diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 0a6fa6bf..ad40bf44 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -305,7 +305,7 @@ namespace sqlpp template auto _run(Db& db) const - -> result_t> + -> result_t())), _result_row_t> { _statement_t::_check_consistency(); static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead"); From e2a7cfa2521310be07f7f3e8334fce5b96e26c01 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 17 Nov 2014 13:16:31 +0100 Subject: [PATCH 016/105] Moved tuple include --- include/sqlpp11/detail/type_set.h | 1 - include/sqlpp11/type_traits.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h index 51e732f5..a9cc7494 100644 --- a/include/sqlpp11/detail/type_set.h +++ b/include/sqlpp11/detail/type_set.h @@ -27,7 +27,6 @@ #ifndef SQLPP_DETAIL_TYPE_SET_H #define SQLPP_DETAIL_TYPE_SET_H -#include #include #include #include diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index a0714bdc..25686dcc 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -28,6 +28,7 @@ #define SQLPP_TYPE_TRAITS_H #include +#include #include namespace sqlpp From 6677266bf5ba71be045cca0d344b24626fedda84 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 17 Nov 2014 13:17:10 +0100 Subject: [PATCH 017/105] Added free function versions of select_column_list and from --- include/sqlpp11/from.h | 5 +++++ include/sqlpp11/select_column_list.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index d5a41cf7..b6c9b4e6 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -220,6 +220,11 @@ namespace sqlpp } }; + template + auto from(T&&... t) -> decltype(statement_t().from(std::forward(t)...)) + { + return statement_t().from(std::forward(t)...); + } } #endif diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index ad40bf44..4dc12f1b 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -420,6 +420,11 @@ namespace sqlpp } }; + template + auto select_columns(T&&... t) -> decltype(statement_t().columns(std::forward(t)...)) + { + return statement_t().columns(std::forward(t)...); + } } #endif From 4ef00a03b21c2c13237f129b9b06e57f07d27670 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 17 Nov 2014 15:03:34 +0100 Subject: [PATCH 018/105] Added central _run/_prepare methods --- include/sqlpp11/statement.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index e0d48437..6f6f5afc 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -189,6 +189,19 @@ namespace sqlpp (void) swallow{(Policies::template _methods_t>::_check_consistency(), 0)...}; } + template + auto _run(Database& db) const -> decltype(std::declval<_result_methods_t>()._run(db)) + { + return _result_methods_t::_run(db); + } + + template + auto _prepare(Database& db) const -> decltype(std::declval<_result_methods_t>()._prepare(db)) + { + return _result_methods_t::_prepare(db); + } + + }; From 59734b3f5103f2effc4e5896f39fbd57c7595032 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 17 Nov 2014 19:05:22 +0100 Subject: [PATCH 019/105] Moved static asserts for inconsistency errors much closer to call site --- include/sqlpp11/custom_query.h | 5 ++- include/sqlpp11/extra_tables.h | 4 +-- include/sqlpp11/from.h | 4 +-- include/sqlpp11/group_by.h | 4 +-- include/sqlpp11/having.h | 4 +-- include/sqlpp11/insert.h | 10 ------ include/sqlpp11/insert_value_list.h | 6 ++-- include/sqlpp11/into.h | 2 +- include/sqlpp11/limit.h | 6 ++-- include/sqlpp11/noop.h | 10 ------ include/sqlpp11/offset.h | 6 ++-- include/sqlpp11/order_by.h | 4 +-- include/sqlpp11/remove.h | 10 ------ include/sqlpp11/select_column_list.h | 14 ++------ include/sqlpp11/select_flag_list.h | 4 +-- include/sqlpp11/single_table.h | 4 +-- include/sqlpp11/statement.h | 52 +++++++++++++++++++++------- include/sqlpp11/type_traits.h | 10 ++++++ include/sqlpp11/update.h | 10 ------ include/sqlpp11/update_list.h | 2 +- include/sqlpp11/using.h | 4 +-- include/sqlpp11/where.h | 25 ++++++++----- tests/MockDb.h | 16 ++++++++- tests/SelectTest.cpp | 8 +++-- 24 files changed, 121 insertions(+), 103 deletions(-) diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 9c77bc72..a64257d1 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -70,17 +70,20 @@ namespace sqlpp custom_query_t& operator=(custom_query_t&&) = default; ~custom_query_t() = default; - static void _check_consistency() {}; + using _consistency_check = consistent_t; template auto _run(Db& db) const -> decltype(std::declval<_methods_t>()._run(db, *this)) { + static_assert(_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead"); + _run_check{}; return _methods_t::_run(db, *this); } template auto _prepare(Db& db) const -> decltype(std::declval<_methods_t>()._prepare(db, *this)) { + _prepare_check{}; return _methods_t::_prepare(db, *this); } diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index d2fe8a73..473479b5 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -99,7 +99,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -142,7 +142,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto extra_tables(Args...) const diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index b6c9b4e6..84d107c9 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -119,7 +119,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -163,7 +163,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto from(Tables... tables) const diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 89792311..e9bd0e9d 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -128,7 +128,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -172,7 +172,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto group_by(Args... args) const diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index cd412c7c..b43f73e9 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -126,7 +126,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -170,7 +170,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto having(Args... args) const diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 59091a04..52f1e749 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -61,18 +61,12 @@ namespace sqlpp auto _run(Db& db, const Composite& composite) const -> decltype(db.insert(composite)) { - Composite::_check_consistency(); - static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); - return db.insert(composite); } template auto _run(Db& db) const -> decltype(db.insert(this->_get_statement())) { - _statement_t::_check_consistency(); - - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); return db.insert(_get_statement()); } @@ -81,8 +75,6 @@ namespace sqlpp auto _prepare(Db& db, const Composite& composite) const -> prepared_insert_t { - Composite::_check_consistency(); - return {{}, db.prepare_insert(composite)}; } @@ -90,8 +82,6 @@ namespace sqlpp auto _prepare(Db& db) const -> prepared_insert_t { - _statement_t::_check_consistency(); - return {{}, db.prepare_insert(_get_statement())}; } }; diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 8f07b51e..c3e63a25 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -96,7 +96,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -200,7 +200,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -288,7 +288,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index e1d2ddd5..e6a5bfdb 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -96,7 +96,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 40b756ce..49266fb8 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -89,7 +89,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -166,7 +166,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -209,7 +209,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto limit(Arg arg) const diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index 1c1b4d61..d2341f1c 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -55,18 +55,12 @@ namespace sqlpp template auto _run(Db& db, const Composite& composite) const -> void { - Composite::_check_consistency(); - static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead"); - return db.execute(composite); } template auto _run(Db& db) const -> void { - _statement_t::_check_consistency(); - - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); return db.execute(_get_statement()); } @@ -75,8 +69,6 @@ namespace sqlpp auto _prepare(Db& db, const Composite& composite) const -> prepared_execute_t { - Composite::_check_consistency(); - return {{}, db.prepare_execute(composite)}; } @@ -84,8 +76,6 @@ namespace sqlpp auto _prepare(Db& db) const -> prepared_execute_t { - _statement_t::_check_consistency(); - return {{}, db.prepare_execute(_get_statement())}; } }; diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index 5d0b4b3b..bc8d6769 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -89,7 +89,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -165,7 +165,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; template void set_offset(Offset value) @@ -220,7 +220,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto offset(Arg arg) const diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index 8d761989..c27cf92b 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -128,7 +128,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -172,7 +172,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto order_by(Args... args) const diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index 00890eaf..a74cc710 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -61,18 +61,12 @@ namespace sqlpp auto _run(Db& db, const Composite& composite) const -> decltype(db.remove(composite)) { - Composite::_check_consistency(); - static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run remove directly with parameters, use prepare instead"); - return db.remove(composite); } template auto _run(Db& db) const -> decltype(db.remove(this->_get_statement())) { - _statement_t::_check_consistency(); - - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run remove directly with parameters, use prepare instead"); return db.remove(_get_statement()); } @@ -81,8 +75,6 @@ namespace sqlpp auto _prepare(Db& db, const Composite& composite) const -> prepared_remove_t { - Composite::_check_consistency(); - return {{}, db.prepare_remove(composite)}; } @@ -90,8 +82,6 @@ namespace sqlpp auto _prepare(Db& db) const -> prepared_remove_t { - _statement_t::_check_consistency(); - return {{}, db.prepare_remove(_get_statement())}; } }; diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 4dc12f1b..627c37ff 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -231,7 +231,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; // Result methods @@ -297,9 +297,6 @@ namespace sqlpp auto _run(Db& db, const Composite& composite) const -> result_t> { - Composite::_check_consistency(); - static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead"); - return {db.select(composite), get_dynamic_names()}; } @@ -307,9 +304,6 @@ namespace sqlpp auto _run(Db& db) const -> result_t())), _result_row_t> { - _statement_t::_check_consistency(); - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead"); - return {db.select(_get_statement()), get_dynamic_names()}; } @@ -318,8 +312,6 @@ namespace sqlpp auto _prepare(Db& db, const Composite& composite) const -> prepared_select_t { - Composite::_check_consistency(); - return {make_parameter_list_t{}, get_dynamic_names(), db.prepare_select(composite)}; } @@ -327,8 +319,6 @@ namespace sqlpp auto _prepare(Db& db) const -> prepared_select_t { - _statement_t::_check_consistency(); - return {make_parameter_list_t<_statement_t>{}, get_dynamic_names(), db.prepare_select(_get_statement())}; } }; @@ -385,7 +375,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto columns(Args... args) const diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 5864816d..afeaa9d4 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -127,7 +127,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -171,7 +171,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto flags(Args... args) const diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index ca6566cb..f30a06c8 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -95,7 +95,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -140,7 +140,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto from(Args... args) const diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 6f6f5afc..26e3fa96 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -43,6 +44,28 @@ namespace sqlpp template struct statement_t; + struct assert_no_unknown_tables_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "one clause requires tables which are otherwise not known in the statement"); + } + }; + + struct assert_no_parameters_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "cannot run statements with parameters directly, use prepare instead"); + } + }; + namespace detail { template @@ -110,7 +133,7 @@ namespace sqlpp struct _recursive_traits { - using _required_tables = statement_policies_t::_required_tables; + using _required_tables = _required_tables; using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; @@ -119,6 +142,16 @@ namespace sqlpp detail::type_set, detail::type_set<>>::type; }; + + using _table_check = typename std::conditional<_required_tables::size::value == 0, + consistent_t, assert_no_unknown_tables_t>::type; + using _parameter_check = typename std::conditional::value == 0, + consistent_t, assert_no_parameters_t>::type; + + using _run_check = detail::get_first_if::_consistency_check...>; + using _prepare_check = detail::get_first_if::_consistency_check...>; }; } @@ -132,6 +165,9 @@ namespace sqlpp public Policies::template _methods_t>... { using _policies_t = typename detail::statement_policies_t; + using _run_check = typename _policies_t::_run_check; + using _prepare_check = typename _policies_t::_prepare_check; + using _result_type_provider = typename _policies_t::_result_type_provider; template using _result_methods_t = typename _result_type_provider::template _result_methods_t; @@ -181,28 +217,20 @@ namespace sqlpp return _policies_t::_can_be_used_as_table(); } - static void _check_consistency() - { - 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[]; - (void) swallow{(Policies::template _methods_t>::_check_consistency(), 0)...}; - } - template auto _run(Database& db) const -> decltype(std::declval<_result_methods_t>()._run(db)) { + _run_check::_(); return _result_methods_t::_run(db); } template auto _prepare(Database& db) const -> decltype(std::declval<_result_methods_t>()._prepare(db)) { + _prepare_check::_(); return _result_methods_t::_prepare(db); } - - }; template @@ -257,7 +285,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 25686dcc..d83b8ab1 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -239,6 +239,16 @@ namespace sqlpp template using derived_statement_t = typename Policies::_statement_t; + + struct consistent_t + { + using type = std::true_type; + + static void _() {}; + }; + + template + using is_inconsistent_t = typename std::conditional::value, std::false_type, std::true_type>::type; } #endif diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index f940fdab..49f4ee85 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -61,18 +61,12 @@ namespace sqlpp auto _run(Db& db, const Composite& composite) const -> decltype(db.update(composite)) { - Composite::_check_consistency(); - static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run update directly with parameters, use prepare instead"); - return db.update(composite); } template auto _run(Db& db) const -> decltype(db.update(this->_get_statement())) { - _statement_t::_check_consistency(); - - static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run update directly with parameters, use prepare instead"); return db.update(_get_statement()); } @@ -81,8 +75,6 @@ namespace sqlpp auto _prepare(Db& db, const Composite& composite) const -> prepared_update_t { - Composite::_check_consistency(); - return {{}, db.prepare_update(composite)}; } @@ -90,8 +82,6 @@ namespace sqlpp auto _prepare(Db& db) const -> prepared_update_t { - _statement_t::_check_consistency(); - return {{}, db.prepare_update(_get_statement())}; } }; diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 425b8b8f..001a61b1 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -124,7 +124,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index c704dfc4..1c67cfa6 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -121,7 +121,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -165,7 +165,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() {} + using _consistency_check = consistent_t; template auto using_(Args... args) const diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 01384545..667fa7f7 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -128,7 +128,7 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; @@ -176,11 +176,22 @@ namespace sqlpp template struct _methods_t { - static void _check_consistency() {} + using _consistency_check = consistent_t; }; }; + struct assert_where_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "where expression required, e.g. where(true)"); + }; + }; + // NO WHERE YET template struct no_where_t @@ -223,12 +234,10 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() - { - static constexpr bool _tables_provided = (Policies::_all_provided_tables::size::value > 0); - static constexpr bool _required = WhereRequired and _tables_provided; - static_assert(not _required, "where expression required, e.g. where(true)"); - } + using _consistency_check = typename std::conditional< + WhereRequired and (Policies::_all_provided_tables::size::value > 0), + assert_where_t, + consistent_t>::type; template auto where(Args... args) const diff --git a/tests/MockDb.h b/tests/MockDb.h index 85bf5630..6b929cfe 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -107,11 +107,25 @@ struct MockDbT: public sqlpp::connection // Directly executed statements start here template - auto operator() (const T& t) -> decltype(t._run(*this)) + auto _run(const T& t, const std::true_type&) -> decltype(t._run(*this)) { return t._run(*this); } + template + auto _run(const T& t, const std::false_type&) -> decltype(t._run(*this)) + { + return decltype(t._run(*this)){}; + } + + template + auto operator() (const T& t) -> decltype(t._run(*this)) + { + T::_run_check::_(); + using _ok = typename T::_run_check::type; + return _run(t, _ok{}); + } + void execute(const std::string& command); template Date: Mon, 17 Nov 2014 19:13:45 +0100 Subject: [PATCH 020/105] Added missing consistency check structs --- include/sqlpp11/insert_value_list.h | 16 ++++++++++++---- include/sqlpp11/into.h | 16 ++++++++++++---- include/sqlpp11/update_list.h | 16 ++++++++++++---- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index c3e63a25..d7355b0a 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -292,6 +292,17 @@ namespace sqlpp }; }; + struct assert_insert_values_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "insert values required, e.g. set(...) or default_values()"); + }; + }; + // NO INSERT COLUMNS/VALUES YET struct no_insert_value_list_t { @@ -332,10 +343,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() - { - static_assert(wrong_t<_methods_t>::value, "insert values required, e.g. set(...) or default_values()"); - } + using _consistency_check = assert_insert_values_t; auto default_values() const -> _new_statement_t diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index e6a5bfdb..71bb48cf 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -101,6 +101,17 @@ namespace sqlpp }; + struct assert_into_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "into() required"); + }; + }; + // NO INTO YET struct no_into_t { @@ -141,10 +152,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() - { - static_assert(wrong_t<_methods_t>::value, "into() required"); - } + using _consistency_check = assert_into_t; template auto into(Args... args) const diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 001a61b1..2b2edcd3 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -128,6 +128,17 @@ namespace sqlpp }; }; + struct assert_update_assignments_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "update assignments required, i.e. set(...)"); + }; + }; + struct no_update_list_t { using _traits = make_traits; @@ -167,10 +178,7 @@ namespace sqlpp template using _new_statement_t = new_statement; - static void _check_consistency() - { - static_assert(wrong_t<_methods_t>::value, "update assignments required, i.e. set(...)"); - } + using _consistency_check = assert_update_assignments_t; template auto set(Assignments... assignments) const From 3f5c48bfd5a909a32ca4a82a8b0fe0ef7707f8ad Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 17 Nov 2014 19:20:55 +0100 Subject: [PATCH 021/105] Fixed run_check and prepared_check for custom query and prepared statemtents --- include/sqlpp11/custom_query.h | 13 ++++++++----- include/sqlpp11/prepared_execute.h | 2 ++ include/sqlpp11/prepared_insert.h | 2 ++ include/sqlpp11/prepared_remove.h | 2 ++ include/sqlpp11/prepared_select.h | 2 ++ include/sqlpp11/prepared_update.h | 2 ++ tests/SelectTest.cpp | 6 +----- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index a64257d1..87826ec0 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -56,6 +56,12 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; + using _parameter_check = typename std::conditional::value == 0, + consistent_t, assert_no_parameters_t>::type; + using _run_check = detail::get_first_if; + using _prepare_check = consistent_t; + custom_query_t(Parts... parts): _parts(parts...) {} @@ -70,20 +76,17 @@ namespace sqlpp custom_query_t& operator=(custom_query_t&&) = default; ~custom_query_t() = default; - using _consistency_check = consistent_t; - template auto _run(Db& db) const -> decltype(std::declval<_methods_t>()._run(db, *this)) { - static_assert(_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead"); - _run_check{}; + _run_check::_(); return _methods_t::_run(db, *this); } template auto _prepare(Db& db) const -> decltype(std::declval<_methods_t>()._prepare(db, *this)) { - _prepare_check{}; + _prepare_check::_(); return _methods_t::_prepare(db, *this); } diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h index e181d37c..e9c27c9d 100644 --- a/include/sqlpp11/prepared_execute.h +++ b/include/sqlpp11/prepared_execute.h @@ -38,6 +38,8 @@ namespace sqlpp using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; + using _run_check = consistent_t; + auto _run(Db& db) const -> void { diff --git a/include/sqlpp11/prepared_insert.h b/include/sqlpp11/prepared_insert.h index e32c73c8..51c759fe 100644 --- a/include/sqlpp11/prepared_insert.h +++ b/include/sqlpp11/prepared_insert.h @@ -38,6 +38,8 @@ namespace sqlpp using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; + using _run_check = consistent_t; + auto _run(Db& db) const -> size_t { diff --git a/include/sqlpp11/prepared_remove.h b/include/sqlpp11/prepared_remove.h index 672ab5a6..3203ee1b 100644 --- a/include/sqlpp11/prepared_remove.h +++ b/include/sqlpp11/prepared_remove.h @@ -38,6 +38,8 @@ namespace sqlpp using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; + using _run_check = consistent_t; + auto _run(Db& db) const -> size_t { diff --git a/include/sqlpp11/prepared_select.h b/include/sqlpp11/prepared_select.h index 2701e17e..40553931 100644 --- a/include/sqlpp11/prepared_select.h +++ b/include/sqlpp11/prepared_select.h @@ -40,6 +40,8 @@ namespace sqlpp using _dynamic_names_t = typename Statement::_dynamic_names_t; using _prepared_statement_t = typename Database::_prepared_statement_t; + using _run_check = consistent_t; + auto _run(Database& db) const -> result_t { diff --git a/include/sqlpp11/prepared_update.h b/include/sqlpp11/prepared_update.h index 8d51b32d..b7f94b86 100644 --- a/include/sqlpp11/prepared_update.h +++ b/include/sqlpp11/prepared_update.h @@ -38,6 +38,8 @@ namespace sqlpp using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; + using _run_check = consistent_t; + auto _run(Db& db) const -> size_t { diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index 1b0f9ef9..76138240 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -38,12 +38,9 @@ MockDb::_serializer_context_t printer; int main() { - //test::TabFoo f; + test::TabFoo f; test::TabBar t; - db(select(all_of(t)).from(t)); - -#if 0 select(t.alpha).flags(sqlpp::all).from(t); for (const auto& row : db(select(all_of(t)).from(t).where(true))) { @@ -101,7 +98,6 @@ int main() std::cerr << serialize(stat, printer).str() << std::endl; select(sqlpp::value(7).as(t.alpha)); -#endif return 0; } From cec105f9dd2510d316597b1ee56817b1c205e6c8 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 17 Nov 2014 19:25:23 +0100 Subject: [PATCH 022/105] Fixed compile error for gcc --- include/sqlpp11/statement.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 26e3fa96..db91baff 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -133,7 +133,7 @@ namespace sqlpp struct _recursive_traits { - using _required_tables = _required_tables; + using _required_tables = statement_policies_t::_required_tables; using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; From f294a876d4a54f1f0618c41168c8a6c302efa8f3 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 17 Nov 2014 19:34:45 +0100 Subject: [PATCH 023/105] Placate clang-3.5 --- tests/ResultTest.cpp | 2 +- tests/SelectTypeTest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ResultTest.cpp b/tests/ResultTest.cpp index 21ca2f82..db12cbcf 100644 --- a/tests/ResultTest.cpp +++ b/tests/ResultTest.cpp @@ -47,7 +47,7 @@ int main() { static_assert(sqlpp::can_be_null_t::value, "row.alpha can be null"); static_assert(sqlpp::null_is_trivial_value_t::value, "row.alpha interprets null_is_trivial"); - static_assert(std::is_member_function_pointer::value, "Yikes"); + static_assert(std::is_same::value, "Yikes"); using T = sqlpp::wrap_operand_t; static_assert(sqlpp::can_be_null_t::value, "row.alpha can be null"); static_assert(sqlpp::is_result_field_t::value, "result_fields are not wrapped"); diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index e9a8ee7d..bd0e9be8 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -359,7 +359,7 @@ int main() ((t.alpha + 7) + 4).asc(); static_assert(sqlpp::is_boolean_t::value, "Comparison expression have to be boolean"); !t.gamma; - t.beta < "kaesekuchen"; + serialize(t.beta < "kaesekuchen", printer).str(); serialize(t.beta + "hallenhalma", printer).str(); static_assert(sqlpp::must_not_insert_t::value, "alpha must not be inserted"); serialize(t.alpha, printer).str(); From 6d2a5e6ac172063ba94698d11439df096923bc70 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 22 Nov 2014 11:09:24 +0100 Subject: [PATCH 024/105] Removed implementation of unwanted dispatch code --- tests/MockDb.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/MockDb.h b/tests/MockDb.h index 6b929cfe..cba48a83 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -113,10 +113,7 @@ struct MockDbT: public sqlpp::connection } template - auto _run(const T& t, const std::false_type&) -> decltype(t._run(*this)) - { - return decltype(t._run(*this)){}; - } + auto _run(const T& t, const std::false_type&) -> decltype(t._run(*this)); template auto operator() (const T& t) -> decltype(t._run(*this)) From 77d737b401158350a918985bf729710a15ecbf6f Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 22 Nov 2014 21:41:43 +0100 Subject: [PATCH 025/105] Minor cleanup in type_sets --- include/sqlpp11/detail/type_set.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h index a9cc7494..3b4d48d6 100644 --- a/include/sqlpp11/detail/type_set.h +++ b/include/sqlpp11/detail/type_set.h @@ -39,6 +39,9 @@ namespace sqlpp template struct make_type_set; + template + using make_type_set_t = typename make_type_set::type; + template struct is_element_of; @@ -49,7 +52,7 @@ namespace sqlpp using size = std::integral_constant; using _is_type_set = std::true_type; - static_assert(std::is_same::type>::value, "use make_type_set to construct a set"); + static_assert(std::is_same>::value, "use make_type_set to construct a typeset"); template struct insert @@ -90,7 +93,7 @@ namespace sqlpp template struct joined_set, type_set> { - using type = typename make_type_set::type; + using type = make_type_set_t; }; template @@ -138,9 +141,6 @@ namespace sqlpp using type = typename make_type_set::type::template insert::type; }; - template - using make_type_set_t = typename make_type_set::type; - template class Predicate, typename... T> struct make_type_set_if; @@ -167,8 +167,11 @@ namespace sqlpp using type = typename make_type_set_if::type; }; + template class Predicate, typename... T> + using make_type_set_if_not_t = typename make_type_set_if_not::type; + template - using has_duplicates = std::integral_constant::type::size::value != sizeof...(T)>; + using has_duplicates = std::integral_constant::size::value != sizeof...(T)>; template struct make_joined_set @@ -204,7 +207,7 @@ namespace sqlpp { template using is_subtrahend = is_element_of>; - using type = typename make_type_set_if_not::type; + using type = make_type_set_if_not_t; }; template @@ -221,7 +224,7 @@ namespace sqlpp { template using is_in_both = all_t>::value, is_element_of>::value>; - using type = typename make_type_set_if::type; + using type = make_type_set_if_t; }; template @@ -237,7 +240,7 @@ namespace sqlpp template class Transformation, typename... E> struct transform_set> { - using type = typename make_type_set...>::type; + using type = make_type_set_t...>; }; template class Transformation, typename T> From e1c007287c79b7bba10fbbf46a0dda81a4f73f18 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 23 Nov 2014 20:06:58 +0100 Subject: [PATCH 026/105] Added portable static asserts --- examples/select.cpp | 33 +++++++++++++++++++++++----- include/sqlpp11/insert_value_list.h | 15 ++++++++++++- include/sqlpp11/select_column_list.h | 15 ++++++++++++- include/sqlpp11/statement.h | 4 ++-- include/sqlpp11/where.h | 1 + 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/examples/select.cpp b/examples/select.cpp index 3bcba136..8b4317c2 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -34,6 +34,9 @@ #include "MockDb.h" #include +static constexpr bool some_condition = true; +static constexpr bool some_other_condition = false; + SQLPP_ALIAS_PROVIDER(cheesecake); MockDb db; @@ -91,8 +94,8 @@ int main() -#if !0 - auto s = select(all_of(p)) +#if 0 + auto s = select(p.id, p.name, f.id.as(cheesecake)) .from(p, f) .where(p.name == any(select(f.name) .from(f) @@ -103,12 +106,32 @@ int main() .limit(3).offset(7); auto x = s.as(sqlpp::alias::x); - for (const auto& row : db(select(p.id, x.name) - .from(p.join(x).on(p.feature == x.feature)) + for (const auto& row : db(select(p.id, p.name, all_of(x).as(x)) + .from(p.join(x).on(p.feature == x.cheesecake)) .where(true))) { int id = row.id; std::string name = row.name; + std::string x_name = row.x.name; + int cheesecake = row.x.cheesecake; + } +#endif + + + +#if !0 + auto dysel = dynamic_select(db).dynamic_columns(p.name).from(p).dynamic_where(); + + if (some_condition) + dysel.selected_columns.add(p.feature); + + if (some_other_condition) + dysel.where.add(p.id > 17); + + for (const auto& row : db(dysel)) + { + std::string name = row.name; + std::string feature = row.at("feature"); } #endif @@ -129,7 +152,5 @@ int main() - - } diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index d7355b0a..b20efded 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -122,6 +122,17 @@ namespace sqlpp interpretable_list_t _dynamic_values; }; + struct assert_no_unknown_tables_in_insert_assignments_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "at least one insert assignment requires a table which is otherwise not known in the statement"); + } + }; + template struct insert_list_t { @@ -200,7 +211,9 @@ namespace sqlpp template struct _methods_t { - using _consistency_check = consistent_t; + using _consistency_check = typename std::conditional::value, + consistent_t, + assert_no_unknown_tables_in_insert_assignments_t>::type; }; }; diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 627c37ff..af247c7f 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -147,6 +147,17 @@ namespace sqlpp dynamic_select_column_list _dynamic_columns; }; + struct assert_no_unknown_tables_in_selected_columns_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "at least one selected column requires a table which is otherwise not known in the statement"); + } + }; + // SELECTED COLUMNS template @@ -231,7 +242,9 @@ namespace sqlpp template struct _methods_t { - using _consistency_check = consistent_t; + using _consistency_check = typename std::conditional::value, + consistent_t, + assert_no_unknown_tables_in_selected_columns_t>::type; }; // Result methods diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index db91baff..31738147 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -149,9 +149,9 @@ namespace sqlpp consistent_t, assert_no_parameters_t>::type; using _run_check = detail::get_first_if::_consistency_check...>; + _parameter_check, typename Policies::template _methods_t::_consistency_check..., _table_check>; using _prepare_check = detail::get_first_if::_consistency_check...>; + typename Policies::template _methods_t::_consistency_check..., _table_check>; }; } diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 667fa7f7..a1de9edc 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -128,6 +128,7 @@ namespace sqlpp template struct _methods_t { +#warning: here and elsewhere: add check for missing tables (see select columns, for instance) using _consistency_check = consistent_t; }; }; From 809d42e4a17f79279a7082b4a87afd8fb6c8590f Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 25 Nov 2014 17:43:55 +0100 Subject: [PATCH 027/105] Introduced check for serializability --- include/sqlpp11/alias.h | 1 + include/sqlpp11/all_of.h | 14 +++++++- include/sqlpp11/any.h | 1 + include/sqlpp11/assignment.h | 1 + include/sqlpp11/avg.h | 1 + include/sqlpp11/boolean_expression.h | 1 + include/sqlpp11/column.h | 1 + include/sqlpp11/concat.h | 1 + include/sqlpp11/count.h | 1 + include/sqlpp11/custom_query.h | 3 +- include/sqlpp11/default_value.h | 1 + include/sqlpp11/exists.h | 1 + include/sqlpp11/expression.h | 5 +++ include/sqlpp11/extra_tables.h | 1 + include/sqlpp11/from.h | 2 ++ include/sqlpp11/functions.h | 1 + include/sqlpp11/group_by.h | 1 + include/sqlpp11/having.h | 1 + include/sqlpp11/hidden.h | 1 + include/sqlpp11/in.h | 1 + include/sqlpp11/insert.h | 1 + include/sqlpp11/insert_value.h | 1 + include/sqlpp11/insert_value_list.h | 3 ++ include/sqlpp11/interpretable.h | 1 + include/sqlpp11/into.h | 1 + include/sqlpp11/is_null.h | 1 + include/sqlpp11/join.h | 1 + include/sqlpp11/like.h | 1 + include/sqlpp11/limit.h | 2 ++ include/sqlpp11/max.h | 1 + include/sqlpp11/min.h | 1 + include/sqlpp11/multi_column.h | 2 ++ include/sqlpp11/named_interpretable.h | 1 + include/sqlpp11/no_data.h | 1 + include/sqlpp11/noop.h | 1 + include/sqlpp11/null.h | 1 + include/sqlpp11/offset.h | 2 ++ include/sqlpp11/on.h | 1 + include/sqlpp11/order_by.h | 1 + include/sqlpp11/parameter.h | 1 + include/sqlpp11/prepared_execute.h | 4 +++ include/sqlpp11/prepared_insert.h | 4 +++ include/sqlpp11/prepared_remove.h | 4 +++ include/sqlpp11/prepared_select.h | 4 +++ include/sqlpp11/prepared_update.h | 4 +++ include/sqlpp11/remove.h | 1 + include/sqlpp11/result_field.h | 1 + include/sqlpp11/rhs_wrap.h | 1 + include/sqlpp11/select.h | 3 +- include/sqlpp11/select_column_list.h | 1 + include/sqlpp11/select_flag_list.h | 1 + include/sqlpp11/select_flags.h | 6 ++++ include/sqlpp11/select_pseudo_table.h | 1 + include/sqlpp11/serialize.h | 10 ------ include/sqlpp11/serializer.h | 16 ++++++++- include/sqlpp11/simple_column.h | 1 + include/sqlpp11/single_table.h | 1 + include/sqlpp11/some.h | 1 + include/sqlpp11/sort_order.h | 1 + include/sqlpp11/statement.h | 10 +++--- include/sqlpp11/sum.h | 1 + include/sqlpp11/table.h | 1 + include/sqlpp11/table_alias.h | 1 + include/sqlpp11/text.h | 1 + include/sqlpp11/tvin.h | 15 +++++++- include/sqlpp11/type_traits.h | 50 +++++++++++++++++++++++++++ include/sqlpp11/update.h | 1 + include/sqlpp11/update_list.h | 1 + include/sqlpp11/using.h | 1 + include/sqlpp11/verbatim.h | 1 + include/sqlpp11/verbatim_table.h | 1 + include/sqlpp11/where.h | 2 ++ include/sqlpp11/wrap_operand.h | 4 +++ tests/MockDb.h | 6 ++-- 74 files changed, 205 insertions(+), 21 deletions(-) diff --git a/include/sqlpp11/alias.h b/include/sqlpp11/alias.h index 61cccb04..22c49dcf 100644 --- a/include/sqlpp11/alias.h +++ b/include/sqlpp11/alias.h @@ -49,6 +49,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = expression_alias_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/all_of.h b/include/sqlpp11/all_of.h index 021da0a8..24c8b5b6 100644 --- a/include/sqlpp11/all_of.h +++ b/include/sqlpp11/all_of.h @@ -51,14 +51,26 @@ namespace sqlpp return {}; } + struct assert_no_stand_alone_all_of_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "all_of(table) seems to be used outside of select"); + } + }; + template struct serializer_t> { + using _serialize_check = assert_no_stand_alone_all_of_t; using T = all_of_t; static Context& _(const T& t, const Context&) { - static_assert(wrong_t::value, "all_of(table) does not seem to be used in select"); + _serialize_check::_(); } }; diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index 79d6aada..2cc6d8a8 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -66,6 +66,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = any_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/expression.h b/include/sqlpp11/expression.h index c467c603..74e6f876 100644 --- a/include/sqlpp11/expression.h +++ b/include/sqlpp11/expression.h @@ -66,6 +66,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = equal_to_t; static Context& _(const T& t, Context& context) @@ -114,6 +115,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = not_equal_to_t; static Context& _(const T& t, Context& context) @@ -158,6 +160,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = logical_not_t; static Context& _(const T& t, Context& context) @@ -205,6 +208,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = binary_expression_t; static Context& _(const T& t, Context& context) @@ -242,6 +246,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = unary_expression_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index 473479b5..3c52eff8 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -157,6 +157,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = extra_tables_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 84d107c9..c1e4fc34 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -78,6 +78,7 @@ namespace sqlpp using _known_tables = detail::make_joined_set_t...>; // Hint: Joins contain more than one table using _known_table_names = detail::transform_set_t; static_assert(not detail::is_element_of::value, "Must not use the same table name twice in from()"); +#warning: need to add a check if the argument is serializable! using ok = detail::all_t<_is_dynamic::value, is_table_t
::value>; @@ -205,6 +206,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = from_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 75eacd90..9172cb81 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -100,6 +100,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of>; using T = value_list_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index e9bd0e9d..6c6fdd09 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -195,6 +195,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = group_by_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index b43f73e9..c0cdb80f 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -193,6 +193,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = having_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/hidden.h b/include/sqlpp11/hidden.h index e9f98cfa..3ceb4f53 100644 --- a/include/sqlpp11/hidden.h +++ b/include/sqlpp11/hidden.h @@ -47,6 +47,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = hidden_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index 3d8a98a0..6726f7b5 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -73,6 +73,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = in_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 52f1e749..9e8b81a4 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -90,6 +90,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = insert_name_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/insert_value.h b/include/sqlpp11/insert_value.h index 061bbd82..4845b217 100644 --- a/include/sqlpp11/insert_value.h +++ b/include/sqlpp11/insert_value.h @@ -103,6 +103,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = insert_value_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index b20efded..b893f641 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -425,6 +425,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = insert_default_values_data_t; static Context& _(const T& t, Context& context) @@ -437,6 +438,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = column_list_data_t; static Context& _(const T& t, Context& context) @@ -464,6 +466,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = insert_list_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/interpretable.h b/include/sqlpp11/interpretable.h index d89075be..2e22ca9d 100644 --- a/include/sqlpp11/interpretable.h +++ b/include/sqlpp11/interpretable.h @@ -114,6 +114,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = interpretable_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index 71bb48cf..b4b86633 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -167,6 +167,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = into_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/is_null.h b/include/sqlpp11/is_null.h index ecc06bd5..bca37cf0 100644 --- a/include/sqlpp11/is_null.h +++ b/include/sqlpp11/is_null.h @@ -69,6 +69,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = is_null_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index e7b444a7..f1097468 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -145,6 +145,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = join_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index 2a73baa3..b5bb9101 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -71,6 +71,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = like_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 49266fb8..5ada9791 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -231,6 +231,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = dynamic_limit_data_t; static Context& _(const T& t, Context& context) @@ -247,6 +248,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = limit_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/max.h b/include/sqlpp11/max.h index 440d1f31..251d6023 100644 --- a/include/sqlpp11/max.h +++ b/include/sqlpp11/max.h @@ -67,6 +67,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = max_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/min.h b/include/sqlpp11/min.h index e5387d37..04bb30cf 100644 --- a/include/sqlpp11/min.h +++ b/include/sqlpp11/min.h @@ -67,6 +67,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = min_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index 44288b83..dce7dce2 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -103,6 +103,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = multi_column_t; static void _(const T& t, Context& context) @@ -114,6 +115,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = multi_column_alias_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/named_interpretable.h b/include/sqlpp11/named_interpretable.h index 5ba0f044..3ec6c1ea 100644 --- a/include/sqlpp11/named_interpretable.h +++ b/include/sqlpp11/named_interpretable.h @@ -123,6 +123,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = named_interpretable_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/no_data.h b/include/sqlpp11/no_data.h index e94a9289..2c0952b4 100644 --- a/include/sqlpp11/no_data.h +++ b/include/sqlpp11/no_data.h @@ -37,6 +37,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = no_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index d2341f1c..62f3b7db 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -84,6 +84,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = noop; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/null.h b/include/sqlpp11/null.h index 93e0706b..0432c387 100644 --- a/include/sqlpp11/null.h +++ b/include/sqlpp11/null.h @@ -40,6 +40,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using Operand = null_t; static Context& _(const Operand& t, Context& context) diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index bc8d6769..4d0f7c1a 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -242,6 +242,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = offset_data_t; static Context& _(const T& t, Context& context) @@ -255,6 +256,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = dynamic_offset_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index 2a88eafb..8762d3c0 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -58,6 +58,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = on_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index c27cf92b..12dc3a8a 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -195,6 +195,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = order_by_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index 687096b3..b5daaabc 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -63,6 +63,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = parameter_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h index e9c27c9d..c328bbc1 100644 --- a/include/sqlpp11/prepared_execute.h +++ b/include/sqlpp11/prepared_execute.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_execute_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_insert.h b/include/sqlpp11/prepared_insert.h index 51c759fe..e81a56c0 100644 --- a/include/sqlpp11/prepared_insert.h +++ b/include/sqlpp11/prepared_insert.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_insert_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_remove.h b/include/sqlpp11/prepared_remove.h index 3203ee1b..d4a4dfad 100644 --- a/include/sqlpp11/prepared_remove.h +++ b/include/sqlpp11/prepared_remove.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_remove_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_select.h b/include/sqlpp11/prepared_select.h index 40553931..70665558 100644 --- a/include/sqlpp11/prepared_select.h +++ b/include/sqlpp11/prepared_select.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_select_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _result_row_t = typename Statement::template _result_row_t; using _parameter_list_t = make_parameter_list_t; using _dynamic_names_t = typename Statement::_dynamic_names_t; diff --git a/include/sqlpp11/prepared_update.h b/include/sqlpp11/prepared_update.h index b7f94b86..4bd54c85 100644 --- a/include/sqlpp11/prepared_update.h +++ b/include/sqlpp11/prepared_update.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_update_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index a74cc710..8d5f43be 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -91,6 +91,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = remove_name_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/result_field.h b/include/sqlpp11/result_field.h index 476ca3ea..9dbdb27a 100644 --- a/include/sqlpp11/result_field.h +++ b/include/sqlpp11/result_field.h @@ -41,6 +41,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = result_field_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/rhs_wrap.h b/include/sqlpp11/rhs_wrap.h index c664d580..610ec634 100644 --- a/include/sqlpp11/rhs_wrap.h +++ b/include/sqlpp11/rhs_wrap.h @@ -147,6 +147,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = rhs_wrap_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 3a2556a5..1da653e0 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -49,12 +49,13 @@ namespace sqlpp { struct select_name_t {}; - struct select_t: public statement_name_t + struct select_t: public statement_name_t {}; template struct serializer_t { + using _serialize_check = consistent_t; using T = select_name_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index af247c7f..4688b3cb 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -411,6 +411,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = select_column_list_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index afeaa9d4..faa41cdf 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -195,6 +195,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = select_flag_list_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index 002bd67a..580d66ab 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -45,6 +45,8 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; + static Context& _(const all_t&, Context& context) { context << "ALL"; @@ -62,6 +64,8 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; + static Context& _(const distinct_t&, Context& context) { context << "DISTINCT"; @@ -79,6 +83,8 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; + static Context& _(const straight_join_t&, Context& context) { context << "STRAIGHT_JOIN"; diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 75f8dbf0..28429e5f 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -75,6 +75,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = select_pseudo_table_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/serialize.h b/include/sqlpp11/serialize.h index e7331320..69e79fe5 100644 --- a/include/sqlpp11/serialize.h +++ b/include/sqlpp11/serialize.h @@ -37,16 +37,6 @@ namespace sqlpp { return serializer_t::_(t, context); } - - /* - template - auto serialize(const T& t, Context& context) - -> decltype(serializer_t::_(t, context)) - { - return serializer_t::_(t, context); - } - */ - } #endif diff --git a/include/sqlpp11/serializer.h b/include/sqlpp11/serializer.h index 04629bda..46261e0e 100644 --- a/include/sqlpp11/serializer.h +++ b/include/sqlpp11/serializer.h @@ -31,12 +31,26 @@ namespace sqlpp { + template + struct assert_serializer_specialization_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "missing serializer specialization"); + } + }; + template struct serializer_t { + using _serialize_check = assert_serializer_specialization_t; + static void _(const T& t, Context& context) { - static_assert(wrong_t::value, "missing serializer specialization"); + _serialize_check::_(); } }; diff --git a/include/sqlpp11/simple_column.h b/include/sqlpp11/simple_column.h index dd1769c6..7bd0c02e 100644 --- a/include/sqlpp11/simple_column.h +++ b/include/sqlpp11/simple_column.h @@ -44,6 +44,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = simple_column_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index f30a06c8..13b8bb20 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -155,6 +155,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = single_table_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/some.h b/include/sqlpp11/some.h index 00dfb755..d457680d 100644 --- a/include/sqlpp11/some.h +++ b/include/sqlpp11/some.h @@ -66,6 +66,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = some_t
::value>; + using ok = detail::all_t<_is_dynamic::value, is_table_t
::value, _serialize_check::type::value>; _add_impl(table, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index be7d01aa..3871d341 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -100,8 +100,10 @@ namespace sqlpp static_assert(_is_dynamic::value, "add() must not be called for static group_by"); static_assert(is_expression_t::value, "invalid expression argument in group_by::add()"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in group_by::add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value>; + using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index e524da76..96764184 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -96,8 +96,10 @@ namespace sqlpp static_assert(_is_dynamic::value, "having::add() can only be called for dynamic_having"); static_assert(is_expression_t::value, "invalid expression argument in having::add()"); static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in having::add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value>; + using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 8190829b..077af67d 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -168,10 +168,13 @@ namespace sqlpp static_assert(not detail::is_element_of, _assigned_columns>::value, "Must not assign value to column twice"); static_assert(not must_not_insert_t>::value, "add() argument must not be used in insert"); static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, "add() contains a column from a foreign table"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); using ok = detail::all_t< _is_dynamic::value, - is_assignment_t::value>; + is_assignment_t::value, + _serialize_check::type::value>; _add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index 8762d3c0..43bd7c80 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -34,40 +34,57 @@ namespace sqlpp { - template + template struct on_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _recursive_traits = make_recursive_traits; using _is_dynamic = is_database; - static_assert(_is_dynamic::value or sizeof...(Expr), "at least one expression argument required in on()"); + static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression argument required in on()"); - template - void add(E expr) + template + void add(Expr expr) { - static_assert(is_expression_t::value, "invalid expression argument in add_on()"); - _dynamic_expressions.emplace_back(expr); + static_assert(_is_dynamic::value, "on::add() must not be called for static on()"); + static_assert(is_expression_t::value, "invalid expression argument in on::add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); + + using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + + _add_impl(expr, ok()); // dispatch to prevent compile messages after the static_assert } - std::tuple _expressions; + private: + template + void _add_impl(Expr expr, const std::true_type&) + { + return _dynamic_expressions.emplace_back(expr); + } + + template + void _add_impl(Expr expr, const std::false_type&); + + public: + std::tuple _expressions; interpretable_list_t _dynamic_expressions; }; - template - struct serializer_t> + template + struct serializer_t> { - using _serialize_check = serialize_check_of; - using T = on_t; + using _serialize_check = serialize_check_of; + using T = on_t; static Context& _(const T& t, Context& context) { - if (sizeof...(Expr) == 0 and t._dynamic_expressions.empty()) + if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty()) return context; context << " ON "; interpret_tuple(t._expressions, " AND ", context); - if (sizeof...(Expr) and not t._dynamic_expressions.empty()) + if (sizeof...(Expressions) and not t._dynamic_expressions.empty()) context << " AND "; interpret_list(t._dynamic_expressions, " AND ", context); return context; diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index afac7e97..ca7c0920 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -100,8 +100,10 @@ namespace sqlpp static_assert(_is_dynamic::value, "add() must not be called for static order_by"); static_assert(is_expression_t::value, "invalid expression argument in order_by::add()"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in order_by::add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value>; + using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 4688b3cb..5b6fcf69 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -198,10 +198,13 @@ namespace sqlpp static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "named expression uses tables unknown to this statement in selected_columns::add()"); using column_names = detail::make_type_set_t; static_assert(not detail::is_element_of::value, "a column of this name is present in the select already"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); using ok = detail::all_t< _is_dynamic::value, - is_selectable_t::value + is_selectable_t::value, + _serialize_check::type::value >; _add_impl(namedExpression, ok()); // dispatch to prevent compile messages after the static_assert diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index faa41cdf..78a42e2b 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -87,8 +87,10 @@ namespace sqlpp static_assert(_is_dynamic::value, "select_flags::add() must not be called for static select flags"); static_assert(is_select_flag_t::value, "invalid select flag argument in select_flags::add()"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "flag uses tables unknown to this statement in select_flags::add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_select_flag_t::value>; + using ok = detail::all_t<_is_dynamic::value, is_select_flag_t::value, _serialize_check::type::value>; _add_impl(flag, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index f17e2c7b..26b6a7e7 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -93,10 +93,13 @@ namespace sqlpp static_assert(not detail::is_element_of, _assigned_columns>::value, "Must not assign value to column twice"); static_assert(detail::not_t>::value, "add() argument must not be updated"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "assignment uses tables unknown to this statement in add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); using ok = detail::all_t< _is_dynamic::value, - is_assignment_t::value>; + is_assignment_t::value, + _serialize_check::type::value>; _add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index 6e2be749..cfc0858a 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -80,8 +80,10 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add must not be called for static using()"); static_assert(is_table_t
::value, "invalid table argument in add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_table_t
::value>; + using ok = detail::all_t<_is_dynamic::value, is_table_t
::value, _serialize_check::type::value>; _add_impl(table, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 983e2658..c518b5af 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -98,8 +98,10 @@ namespace sqlpp static_assert(_is_dynamic::value, "where::add() can only be called for dynamic_where"); static_assert(is_expression_t::value, "invalid expression argument in where::add()"); static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in where::add()"); + using _serialize_check = sqlpp::serialize_check_t; + _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value>; + using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } From 443614a0e7e3aa7ee8c2ef62885175b9e6e9a5ed Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 27 Nov 2014 22:16:12 +0100 Subject: [PATCH 031/105] Reduced compiler error spew dramatically for from and having. --- include/sqlpp11/bad_statement.h | 41 ++++++++++++++++++++++++++++ include/sqlpp11/from.h | 27 ++++++++++++------ include/sqlpp11/group_by.h | 34 +++++++++++++---------- include/sqlpp11/having.h | 44 +++++++++++++++++++++--------- include/sqlpp11/order_by.h | 38 +++++++++++++++----------- include/sqlpp11/policy_update.h | 16 +++++++++++ include/sqlpp11/select_flag_list.h | 32 ++++++++++++++-------- include/sqlpp11/sort_order.h | 2 +- 8 files changed, 169 insertions(+), 65 deletions(-) create mode 100644 include/sqlpp11/bad_statement.h diff --git a/include/sqlpp11/bad_statement.h b/include/sqlpp11/bad_statement.h new file mode 100644 index 00000000..16b3f7e4 --- /dev/null +++ b/include/sqlpp11/bad_statement.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_BAD_STATEMENT_H +#define SQLPP_BAD_STATEMENT_H + +namespace sqlpp +{ + struct bad_statement + { + template + bad_statement(T&&...) {} + }; +} + +#endif + + diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 1534be1f..6d34b994 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -163,33 +163,42 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto from(Tables... tables) const - -> _new_statement_t> + -> _new_statement_t<_check, from_t> { + static_assert(_check::value, "at least one argument is not a table or join in from()"); static_assert(sizeof...(Tables), "at least one table or join argument required in from()"); - return _from_impl(tables...); + return _from_impl(_check{}, tables...); } template auto dynamic_from(Tables... tables) const - -> _new_statement_t> + -> _new_statement_t<_check, from_t<_database_t, Tables...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_from must not be called in a static statement"); - return _from_impl<_database_t>(tables...); + static_assert(_check::value, "at least one argument is not a table or join in from()"); + return _from_impl<_database_t>(_check{}, tables...); } private: template - auto _from_impl(Tables... tables) const - -> _new_statement_t> + auto _from_impl(const std::false_type&, Tables... tables) const + -> _new_statement_t>; + + template + auto _from_impl(const std::true_type&, Tables... tables) const + -> _new_statement_t> { - static_assert(detail::all_t::value...>::value, "at least one argument is not a table or join in from()"); static_assert(required_tables_of>::size::value == 0, "at least one table depends on another table"); static constexpr std::size_t _number_of_tables = detail::sum(provided_tables_of::size::value...); diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 3871d341..acb2833d 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -75,12 +75,6 @@ namespace sqlpp using _is_dynamic = is_database; - static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression (e.g. a column) required in group_by()"); - - static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in group_by()"); - - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); - // Data using _data_t = group_by_data_t; @@ -189,20 +183,32 @@ namespace sqlpp using _consistency_check = consistent_t; - template - auto group_by(Args... args) const - -> _new_statement_t> + template + auto group_by(Expressions... expressions) const + -> _new_statement_t> { - return { static_cast&>(*this), group_by_data_t{args...} }; + static_assert(sizeof...(Expressions), "at least one expression (e.g. a column) required in group_by()"); + return _group_by_impl(expressions...); } - template - auto dynamic_group_by(Args... args) const - -> _new_statement_t> + template + auto dynamic_group_by(Expressions... expressions) const + -> _new_statement_t> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_group_by must not be called in a static statement"); - return { static_cast&>(*this), group_by_data_t<_database_t, Args...>{args...} }; + return _group_by_impl<_database_t>(expressions...); } + + private: + template + auto _group_by_impl(Expressions... expressions) const + -> _new_statement_t> + { + static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in group_by()"); + static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); + + return { static_cast&>(*this), group_by_data_t{expressions...} }; + }; }; }; diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index 96764184..35580118 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -74,9 +74,6 @@ namespace sqlpp using _is_dynamic = is_database; - static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression argument required in having()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in having()"); - // Data using _data_t = having_data_t; @@ -182,25 +179,46 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; - template - auto having(Args... args) const - -> _new_statement_t> + template + auto having(Expressions... expressions) const + -> _new_statement_t<_check, having_t> { - return { static_cast&>(*this), having_data_t{args...} }; + static_assert(_check::value, "at least one argument is not an expression in having()"); + static_assert(sizeof...(Expressions), "at least one expression argument required in having()"); + + return _having_impl(_check{}, expressions...); } - template - auto dynamic_having(Args... args) const - -> _new_statement_t> + template + auto dynamic_having(Expressions... expressions) const + -> _new_statement_t<_check, having_t<_database_t, Expressions...>> { + static_assert(_check::value, "at least one argument is not an expression in having()"); static_assert(not std::is_same<_database_t, void>::value, "dynamic_having must not be called in a static statement"); - return { static_cast&>(*this), having_data_t<_database_t, Args...>{args...} }; + return _having_impl<_database_t>(_check{}, expressions...); } + + private: + template + auto _having_impl(const std::false_type&, Expressions... expressions) const + -> bad_statement; + + template + auto _having_impl(const std::true_type&, Expressions... expressions) const + -> _new_statement_t> + { + return { static_cast&>(*this), having_data_t<_database_t, Expressions...>{expressions...} }; + } + }; }; diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index ca7c0920..e9929aef 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -75,12 +75,6 @@ namespace sqlpp using _is_dynamic = is_database; - static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression (e.g. a column) required in order_by()"); - - static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in order_by()"); - - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); - // Data using _data_t = order_by_data_t; @@ -98,12 +92,12 @@ namespace sqlpp void add(Expression expression) { static_assert(_is_dynamic::value, "add() must not be called for static order_by"); - static_assert(is_expression_t::value, "invalid expression argument in order_by::add()"); + static_assert(is_sort_order_t::value, "invalid expression argument in order_by::add()"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in order_by::add()"); using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = detail::all_t<_is_dynamic::value, is_sort_order_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } @@ -189,20 +183,32 @@ namespace sqlpp using _consistency_check = consistent_t; - template - auto order_by(Args... args) const - -> _new_statement_t> + template + auto order_by(Expressions... expressions) const + -> _new_statement_t> { - return { static_cast&>(*this), order_by_data_t{args...} }; + static_assert(sizeof...(Expressions), "at least one expression (e.g. a column) required in order_by()"); + return _order_by_impl(expressions...); } - template - auto dynamic_order_by(Args... args) const - -> _new_statement_t> + template + auto dynamic_order_by(Expressions... expressions) const + -> _new_statement_t> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_order_by must not be called in a static statement"); - return { static_cast&>(*this), order_by_data_t<_database_t, Args...>{args...} }; + return _order_by_impl<_database_t>(expressions...); } + + private: + template + auto _order_by_impl(Expressions... expressions) const + -> _new_statement_t> + { + static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in order_by()"); + static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); + + return { static_cast&>(*this), order_by_data_t{expressions...} }; + }; }; }; diff --git a/include/sqlpp11/policy_update.h b/include/sqlpp11/policy_update.h index 1afd9c24..68e31ccc 100644 --- a/include/sqlpp11/policy_update.h +++ b/include/sqlpp11/policy_update.h @@ -28,6 +28,7 @@ #define SQLPP_POLICY_UPDATE_H #include +#include namespace sqlpp { @@ -53,6 +54,21 @@ namespace sqlpp template using new_statement = typename Policies::template _new_statement_t; + template + struct new_statement_impl + { + using type = typename Policies::template _new_statement_t; + }; + + template + struct new_statement_impl + { + using type = bad_statement; + }; + + template + using new_statement_t = typename new_statement_impl::type; + } #endif diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 78a42e2b..d35c687d 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -64,10 +64,6 @@ namespace sqlpp using _is_dynamic = is_database; - static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in select flag list"); - - static_assert(detail::all_t::value...>::value, "at least one argument is not a select flag in select flag list"); - // Data using _data_t = select_flag_list_data_t; @@ -175,20 +171,32 @@ namespace sqlpp using _consistency_check = consistent_t; - template - auto flags(Args... args) const - -> _new_statement_t> + template + auto flags(Flags... flags) const + -> _new_statement_t> { - return { static_cast&>(*this), select_flag_list_data_t{args...} }; + return _flags_impl(flags...); } - template - auto dynamic_flags(Args... args) const - -> _new_statement_t> + template + auto dynamic_flags(Flags... flags) const + -> _new_statement_t> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_flags must not be called in a static statement"); - return { static_cast&>(*this), select_flag_list_data_t<_database_t, Args...>{args...} }; + return _flags_impl<_database_t>(flags...); } + + private: + template + auto _flags_impl(Flags... flags) const + -> _new_statement_t> + { + static_assert(detail::all_t::value...>::value, "at least one argument is not a select flag in select flag list"); + static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in select flag list"); + + return { static_cast&>(*this), select_flag_list_data_t{flags...} }; + } + }; }; diff --git a/include/sqlpp11/sort_order.h b/include/sqlpp11/sort_order.h index edd15269..04cfaab7 100644 --- a/include/sqlpp11/sort_order.h +++ b/include/sqlpp11/sort_order.h @@ -41,7 +41,7 @@ namespace sqlpp template struct sort_order_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits; Expression _expression; From 36d1a8533963a9e72d8e22116b4b59af849a95c2 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 27 Nov 2014 23:11:46 +0100 Subject: [PATCH 032/105] Reduced error messages for insert value lists --- include/sqlpp11/from.h | 2 +- include/sqlpp11/group_by.h | 29 ++++++--- include/sqlpp11/insert_value_list.h | 91 +++++++++++++++++------------ 3 files changed, 76 insertions(+), 46 deletions(-) diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 6d34b994..41a932d3 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -193,7 +193,7 @@ namespace sqlpp private: template auto _from_impl(const std::false_type&, Tables... tables) const - -> _new_statement_t>; + -> bad_statement; template auto _from_impl(const std::true_type&, Tables... tables) const diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index acb2833d..65e8d5ff 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -178,34 +178,45 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto group_by(Expressions... expressions) const - -> _new_statement_t> + -> _new_statement_t<_check, group_by_t> { static_assert(sizeof...(Expressions), "at least one expression (e.g. a column) required in group_by()"); - return _group_by_impl(expressions...); + static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); + + return _group_by_impl(_check{}, expressions...); } template auto dynamic_group_by(Expressions... expressions) const - -> _new_statement_t> + -> _new_statement_t<_check, group_by_t<_database_t, Expressions...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_group_by must not be called in a static statement"); - return _group_by_impl<_database_t>(expressions...); + static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); + + return _group_by_impl<_database_t>(_check{}, expressions...); } private: template - auto _group_by_impl(Expressions... expressions) const - -> _new_statement_t> + auto _group_by_impl(const std::false_type&, Expressions... expressions) const + -> bad_statement; + + template + auto _group_by_impl(const std::true_type&, Expressions... expressions) const + -> _new_statement_t> { static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in group_by()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); return { static_cast&>(*this), group_by_data_t{expressions...} }; }; diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 077af67d..2e136716 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -41,20 +41,20 @@ namespace sqlpp { namespace detail { - template - struct first_arg_impl + template + struct have_all_required_columns { - static_assert(wrong_t::value, "At least one argument required"); + static constexpr bool value = false; }; - template - struct first_arg_impl + template + struct have_all_required_columns { - using type = T; + using _table = typename First::_table; + using required_columns = typename _table::_required_insert_columns; + using set_columns = detail::make_type_set_t; + static constexpr bool value = detail::is_subset_of::value; }; - - template - using first_arg_t = typename first_arg_impl::type; } struct insert_default_values_data_t @@ -369,62 +369,79 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _column_check = detail::all_t::value...>; + + template + using _assignment_check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = assert_insert_values_t; auto default_values() const - -> _new_statement_t + -> _new_statement_t { return { static_cast&>(*this), insert_default_values_data_t{} }; } template auto columns(Columns... columns) const - -> _new_statement_t> + -> _new_statement_t<_column_check, column_list_t> { - static_assert(sizeof...(Columns), "at least one column required in columns()"); - static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in columns()"); static_assert(detail::all_t::value...>::value, "at least one argument is not a column in columns()"); - static_assert(detail::none_t::value...>::value, "at least one column argument has a must_not_insert tag in its definition"); - using _column_required_tables = detail::make_joined_set_t...>; - static_assert(_column_required_tables::size::value == 1, "columns() contains columns from several tables"); + static_assert(sizeof...(Columns), "at least one column required in columns()"); - using _table = typename detail::first_arg_t::_table; - using required_columns = typename _table::_required_insert_columns; - using set_columns = detail::make_type_set_t; - static_assert(detail::is_subset_of::value, "At least one required column is missing in columns()"); - - return { static_cast&>(*this), column_list_data_t{columns...} }; + return _columns_impl(_column_check{}, columns...); } template auto set(Assignments... assignments) const - -> _new_statement_t> + -> _new_statement_t<_assignment_check, insert_list_t> { + static_assert(_assignment_check::value, "at least one argument is not an assignment in set()"); static_assert(sizeof...(Assignments), "at least one assignment expression required in set()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an assignment in set()"); - using _table = typename lhs_t>::_table; - using required_columns = typename _table::_required_insert_columns; - using columns = detail::make_type_set_t...>; - static_assert(detail::is_subset_of::value, "At least one required column is missing in set()"); - return _set_impl(assignments...); + return _set_impl(_assignment_check{}, assignments...); } template auto dynamic_set(Assignments... assignments) const - -> _new_statement_t> + -> _new_statement_t<_assignment_check, insert_list_t<_database_t, Assignments...>> { + static_assert(_assignment_check::value, "at least one argument is not an assignment in set()"); static_assert(not std::is_same<_database_t, void>::value, "dynamic_set must not be called in a static statement"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an assignment in set()"); - return _set_impl<_database_t>(assignments...); + + return _set_impl<_database_t>(_assignment_check{}, assignments...); } private: + template + auto _columns_impl(const std::false_type&, Columns... columns) const + -> bad_statement; + + template + auto _columns_impl(const std::true_type&, Columns... columns) const + -> _new_statement_t> + { + static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in columns()"); + static_assert(detail::none_t::value...>::value, "at least one column argument has a must_not_insert tag in its definition"); + using _column_required_tables = detail::make_joined_set_t...>; + static_assert(_column_required_tables::size::value == 1, "columns() contains columns from several tables"); + + static_assert(detail::have_all_required_columns::value, "At least one required column is missing in columns()"); + + return { static_cast&>(*this), column_list_data_t{columns...} }; + } + template - auto _set_impl(Assignments... assignments) const - -> _new_statement_t> + auto _set_impl(const std::false_type&, Assignments... assignments) const + -> bad_statement; + + template + auto _set_impl(const std::true_type&, Assignments... assignments) const + -> _new_statement_t> { static_assert(not detail::has_duplicates...>::value, "at least one duplicate column detected in set()"); static_assert(detail::none_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()"); @@ -432,6 +449,8 @@ namespace sqlpp using _column_required_tables = detail::make_joined_set_t>...>; static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true, "set() contains assignments for columns from several tables"); + static_assert(not std::is_same<_database_t, void>::value or detail::have_all_required_columns...>::value, "At least one required column is missing in set()"); + return { static_cast&>(*this), insert_list_data_t{assignments...} }; } }; From bf2744d5f7b5270049ae52b7d34e00242f8ab3fe Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 27 Nov 2014 23:18:23 +0100 Subject: [PATCH 033/105] Reduced error messages for order_by --- include/sqlpp11/order_by.h | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index e9929aef..cc893efb 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -178,34 +178,45 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto order_by(Expressions... expressions) const - -> _new_statement_t> + -> _new_statement_t<_check, order_by_t> { static_assert(sizeof...(Expressions), "at least one expression (e.g. a column) required in order_by()"); - return _order_by_impl(expressions...); + static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); + + return _order_by_impl(_check{}, expressions...); } template auto dynamic_order_by(Expressions... expressions) const - -> _new_statement_t> + -> _new_statement_t<_check, order_by_t<_database_t, Expressions...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_order_by must not be called in a static statement"); - return _order_by_impl<_database_t>(expressions...); + static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); + + return _order_by_impl<_database_t>(_check{}, expressions...); } private: template - auto _order_by_impl(Expressions... expressions) const - -> _new_statement_t> + auto _order_by_impl(const std::false_type&, Expressions... expressions) const + -> bad_statement; + + template + auto _order_by_impl(const std::true_type&, Expressions... expressions) const + -> _new_statement_t> { static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in order_by()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); return { static_cast&>(*this), order_by_data_t{expressions...} }; }; From 8d6816be8b8307bc5199b4b0e00510ec5cf68f1d Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 28 Nov 2014 10:10:34 +0100 Subject: [PATCH 034/105] Fixed order_by type check --- include/sqlpp11/group_by.h | 4 ++-- include/sqlpp11/order_by.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 65e8d5ff..9d5a3965 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -192,7 +192,7 @@ namespace sqlpp -> _new_statement_t<_check, group_by_t> { static_assert(sizeof...(Expressions), "at least one expression (e.g. a column) required in group_by()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); + static_assert(_check::value, "at least one argument is not an expression in group_by()"); return _group_by_impl(_check{}, expressions...); } @@ -202,7 +202,7 @@ namespace sqlpp -> _new_statement_t<_check, group_by_t<_database_t, Expressions...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_group_by must not be called in a static statement"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in group_by()"); + static_assert(_check::value, "at least one argument is not an expression in group_by()"); return _group_by_impl<_database_t>(_check{}, expressions...); } diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index cc893efb..aa7fc9ad 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -180,7 +180,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = detail::all_t::value...>; template using _new_statement_t = new_statement_t; @@ -192,7 +192,7 @@ namespace sqlpp -> _new_statement_t<_check, order_by_t> { static_assert(sizeof...(Expressions), "at least one expression (e.g. a column) required in order_by()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); + static_assert(_check::value, "at least one argument is not a sort order in order_by()"); return _order_by_impl(_check{}, expressions...); } @@ -202,7 +202,7 @@ namespace sqlpp -> _new_statement_t<_check, order_by_t<_database_t, Expressions...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_order_by must not be called in a static statement"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in order_by()"); + static_assert(_check::value, "at least one argument is not a sort order in order_by()"); return _order_by_impl<_database_t>(_check{}, expressions...); } From 94be5621671c046a3fa52c66c770bff4669f242a Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 28 Nov 2014 10:11:01 +0100 Subject: [PATCH 035/105] Reduced error messages for select columns. Due to the some args being selectables and others being tuples of selectables, this is a bit more complex than the other clauses. --- include/sqlpp11/select_column_list.h | 62 ++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 5b6fcf69..c0f86360 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -170,11 +170,6 @@ namespace sqlpp using _is_dynamic = is_database; - static_assert(_is_dynamic::value or sizeof...(Columns), "at least one select expression required"); - static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected"); - static_assert(detail::all_t<(is_selectable_t::value or is_multi_column_t::value)...>::value, "at least one argument is not a named expression"); - static_assert(not detail::has_duplicates::value, "at least one duplicate name detected"); - struct _column_type {}; // Data @@ -343,10 +338,17 @@ namespace sqlpp namespace detail { + template + auto tuple_merge(Columns... columns) -> decltype(std::tuple_cat(as_tuple::_(columns)...)) + { + return std::tuple_cat(as_tuple::_(columns)...); + }; + template using make_select_column_list_t = copy_tuple_args_t::_(std::declval())...))>; + decltype(tuple_merge(std::declval()...))>; + } struct no_select_column_list_t @@ -388,24 +390,60 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t<(is_selectable_t::value or is_multi_column_t::value)...>; + + template + static constexpr auto _check_tuple(std::tuple) -> _check + { + return {}; + } + + template + static constexpr auto _check_args(T... args) -> decltype(_check_tuple(detail::tuple_merge(args...))) + { + return _check_tuple(detail::tuple_merge(args...)); + } + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto columns(Args... args) const - -> _new_statement_t> + -> _new_statement_t> { - return { static_cast&>(*this), typename detail::make_select_column_list_t::_data_t{std::tuple_cat(detail::as_tuple::_(args)...)} }; + static_assert(sizeof...(Args), "at least one selectable expression (e.g. a column) required in columns()"); + static_assert(decltype(_check_args(args...))::value, "at least one argument is not a selectable expression in columns()"); + + return _columns_impl<_database_t>(_check_args(args...), detail::tuple_merge(args...)); } template auto dynamic_columns(Args... args) const - -> _new_statement_t> + -> _new_statement_t> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_columns must not be called in a static statement"); - return { static_cast&>(*this), typename detail::make_select_column_list_t<_database_t, Args...>::_data_t{std::tuple_cat(detail::as_tuple::_(args)...)} }; + static_assert(decltype(_check_args(args...))::value, "at least one argument is not a selectable expression in columns()"); + + return _columns_impl<_database_t>(_check_args(args...), detail::tuple_merge(args...)); + } + + private: + template + auto _columns_impl(const std::false_type&, std::tuple args) const + -> bad_statement; + + template + auto _columns_impl(const std::true_type&, std::tuple args) const + -> _new_statement_t<_check, select_column_list_t> + { + static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected"); + static_assert(not detail::has_duplicates::value, "at least one duplicate name detected"); + + return { static_cast&>(*this), typename select_column_list_t::_data_t{args} }; } }; }; From f83d77ddb5b80607618f2527e0d40d8bbeba1742 Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 28 Nov 2014 11:20:27 +0100 Subject: [PATCH 036/105] Reduced error messages for select_flags --- include/sqlpp11/select_flag_list.h | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index d35c687d..71461aba 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -166,32 +166,43 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto flags(Flags... flags) const - -> _new_statement_t> + -> _new_statement_t<_check, select_flag_list_t> { - return _flags_impl(flags...); + static_assert(_check::value, "at least one argument is not a select flag in select flag list"); + + return _flags_impl(_check{}, flags...); } template auto dynamic_flags(Flags... flags) const - -> _new_statement_t> + -> _new_statement_t<_check, 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"); - return _flags_impl<_database_t>(flags...); + static_assert(_check::value, "at least one argument is not a select flag in select flag list"); + + return _flags_impl<_database_t>(_check{}, flags...); } private: template - auto _flags_impl(Flags... flags) const - -> _new_statement_t> + auto _flags_impl(const std::false_type&, Flags... flags) const + -> bad_statement; + + template + auto _flags_impl(const std::true_type&, Flags... flags) const + -> _new_statement_t> { - static_assert(detail::all_t::value...>::value, "at least one argument is not a select flag in select flag list"); static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in select flag list"); return { static_cast&>(*this), select_flag_list_data_t{flags...} }; From 7f97f2bbe79b964ac1c2a61e39292062f1b46a5f Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 29 Nov 2014 09:18:20 +0100 Subject: [PATCH 037/105] Reduced error messages for 'using' and update list --- include/sqlpp11/update_list.h | 29 ++++++++++++++++-------- include/sqlpp11/using.h | 42 +++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 26b6a7e7..e32b2400 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -191,33 +191,44 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = assert_update_assignments_t; template auto set(Assignments... assignments) const - -> _new_statement_t> + -> _new_statement_t<_check, update_list_t> { static_assert(sizeof...(Assignments), "at least one assignment expression required in set()"); - return _set_impl(assignments...); + static_assert(_check::value, "at least one argument is not an assignment in set()"); + + return _set_impl(_check{}, assignments...); } template auto dynamic_set(Assignments... assignments) const - -> _new_statement_t> + -> _new_statement_t<_check, 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"); - return _set_impl<_database_t>(assignments...); + static_assert(_check::value, "at least one argument is not an assignment in set()"); + + return _set_impl<_database_t>(_check{}, assignments...); } private: template - auto _set_impl(Assignments... assignments) const - -> _new_statement_t> + auto _set_impl(const std::false_type&, Assignments... assignments) const + -> bad_statement; + + template + auto _set_impl(const std::true_type&, Assignments... assignments) const + -> _new_statement_t> { - static_assert(detail::all_t::value...>::value, "at least one argument is not an assignment in set()"); static_assert(not detail::has_duplicates...>::value, "at least one duplicate column detected in set()"); static_assert(detail::none_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()"); diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index cfc0858a..e743e0ae 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -62,12 +62,6 @@ namespace sqlpp using _is_dynamic = is_database; - static_assert(_is_dynamic::value or sizeof...(Tables), "at least one table argument required in using()"); - - static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in using()"); - - static_assert(detail::all_t::value...>::value, "at least one argument is not an table in using()"); - // Data using _data_t = using_data_t; @@ -165,25 +159,49 @@ namespace sqlpp struct _methods_t { using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto using_(Args... args) const - -> _new_statement_t> + -> _new_statement_t<_check, using_t> { - return { static_cast&>(*this), using_data_t{args...} }; + static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in using()"); + static_assert(sizeof...(Args), "at least one table required in using()"); + static_assert(_check::value, "at least one argument is not an table in using()"); + + return { _using_impl(_check{}, args...) }; } template auto dynamic_using(Args... args) const - -> _new_statement_t> + -> _new_statement_t<_check, using_t<_database_t, Args...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_using must not be called in a static statement"); - return { static_cast&>(*this), using_data_t<_database_t, Args...>{args...} }; + static_assert(_check::value, "at least one argument is not an table in using()"); + + return { _using_impl<_database_t>(_check{}, args...) }; } + + private: + template + auto _using_impl(const std::false_type&, Args... args) const + -> bad_statement; + + template + auto _using_impl(const std::true_type&, Args... args) const + -> _new_statement_t> + { + static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in using()"); + + return { static_cast&>(*this), using_data_t{args...} }; + }; }; }; From 375c277402d369e25251db4e23ca330a7e667a16 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 29 Nov 2014 09:45:40 +0100 Subject: [PATCH 038/105] Fixed bug in select_columns --- include/sqlpp11/select_column_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index c0f86360..96b28785 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -418,7 +418,7 @@ namespace sqlpp static_assert(sizeof...(Args), "at least one selectable expression (e.g. a column) required in columns()"); static_assert(decltype(_check_args(args...))::value, "at least one argument is not a selectable expression in columns()"); - return _columns_impl<_database_t>(_check_args(args...), detail::tuple_merge(args...)); + return _columns_impl(_check_args(args...), detail::tuple_merge(args...)); } template From f62891d25f95829b1b4e8343c645f7239740d881 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 29 Nov 2014 11:10:01 +0100 Subject: [PATCH 039/105] Merged _member and _methods in clauses to _base This makes statement_t look much nicer and use less inheritance --- include/sqlpp11/extra_tables.h | 18 ++++-------- include/sqlpp11/from.h | 18 +++--------- include/sqlpp11/group_by.h | 16 +++-------- include/sqlpp11/having.h | 17 +++-------- include/sqlpp11/insert_value_list.h | 34 ++++++---------------- include/sqlpp11/into.h | 19 ++++--------- include/sqlpp11/limit.h | 26 +++++------------ include/sqlpp11/offset.h | 24 ++++------------ include/sqlpp11/order_by.h | 16 +++-------- include/sqlpp11/select_column_list.h | 18 +++--------- include/sqlpp11/select_flag_list.h | 17 +++-------- include/sqlpp11/single_table.h | 17 +++-------- include/sqlpp11/statement.h | 42 +++++++++++----------------- include/sqlpp11/update_list.h | 17 +++-------- include/sqlpp11/using.h | 17 +++-------- include/sqlpp11/where.h | 27 ++++-------------- 16 files changed, 90 insertions(+), 253 deletions(-) diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index 3c52eff8..28d17f5b 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -78,9 +78,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = extra_tables_data_t; @@ -93,12 +93,7 @@ namespace sqlpp { return t.extra_tables; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = consistent_t; }; }; @@ -119,9 +114,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -134,11 +129,7 @@ namespace sqlpp { return t.no_extra_tables; } - }; - template - struct _methods_t - { template using _new_statement_t = new_statement; @@ -148,6 +139,7 @@ namespace sqlpp auto extra_tables(Args...) const -> _new_statement_t> { +#warning: need to move static asserts return { static_cast&>(*this), extra_tables_data_t{} }; } }; diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 41a932d3..a821c001 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -100,9 +100,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = from_data_t; @@ -115,12 +115,7 @@ namespace sqlpp { return t.from; } - }; - // Additional methods for the statement - template - struct _methods_t - { // FIXME: We might want to check if we have too many tables define in the FROM using _consistency_check = consistent_t; }; @@ -141,9 +136,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -156,12 +151,7 @@ namespace sqlpp { return t.no_from; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 9d5a3965..9b1e4234 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -115,9 +115,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = group_by_data_t; @@ -130,11 +130,7 @@ namespace sqlpp { return t.group_by; } - }; - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_group_by_t>::type; @@ -157,9 +153,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -172,11 +168,7 @@ namespace sqlpp { return t.no_group_by; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index 35580118..28812576 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -115,9 +115,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = having_data_t; @@ -130,12 +130,7 @@ namespace sqlpp { return t.having; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_having_t>::type; @@ -158,9 +153,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -173,11 +168,7 @@ namespace sqlpp { return t.no_having; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 2e136716..31893849 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -76,9 +76,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = insert_default_values_data_t; @@ -91,11 +91,7 @@ namespace sqlpp { return t.default_values; } - }; - template - struct _methods_t - { using _consistency_check = consistent_t; }; }; @@ -193,9 +189,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = insert_list_data_t; @@ -208,12 +204,7 @@ namespace sqlpp { return t.insert_list; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_insert_assignments_t>::type; @@ -294,9 +285,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = column_list_data_t; @@ -309,12 +300,7 @@ namespace sqlpp { return t.values; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_column_list_t>::type; @@ -348,9 +334,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -363,11 +349,7 @@ namespace sqlpp { return t.no_insert_values; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index b4b86633..d4a19928 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -75,9 +75,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = into_data_t; @@ -90,12 +90,7 @@ namespace sqlpp { return t.into; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = consistent_t; }; @@ -109,7 +104,7 @@ namespace sqlpp static void _() { static_assert(wrong_t::value, "into() required"); - }; + } }; // NO INTO YET @@ -128,9 +123,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -143,11 +138,7 @@ namespace sqlpp { return t.no_into; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template using _new_statement_t = new_statement; diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 5ada9791..33fa840f 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -69,9 +69,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = limit_data_t; @@ -84,11 +84,7 @@ namespace sqlpp { return t.limit; } - }; - template - struct _methods_t - { using _consistency_check = consistent_t; }; }; @@ -145,9 +141,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = dynamic_limit_data_t; @@ -160,12 +156,7 @@ namespace sqlpp { return t.limit; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = consistent_t; }; }; @@ -185,9 +176,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -200,12 +191,9 @@ namespace sqlpp { return t.no_limit; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; + template using _new_statement_t = new_statement; diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index 4d0f7c1a..44ddc69d 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -69,9 +69,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = offset_data_t; @@ -84,11 +84,7 @@ namespace sqlpp { return t.offset; } - }; - template - struct _methods_t - { using _consistency_check = consistent_t; }; }; @@ -145,9 +141,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = dynamic_offset_data_t; @@ -160,11 +156,7 @@ namespace sqlpp { return t.offset; } - }; - template - struct _methods_t - { using _consistency_check = consistent_t; template @@ -196,9 +188,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -211,11 +203,7 @@ namespace sqlpp { return t.no_offset; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template using _new_statement_t = new_statement; diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index aa7fc9ad..87383943 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -115,9 +115,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = order_by_data_t; @@ -130,11 +130,7 @@ namespace sqlpp { return t.order_by; } - }; - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_order_by_t>::type; @@ -157,9 +153,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -172,11 +168,7 @@ namespace sqlpp { return t.no_order_by; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 96b28785..d4244cf8 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -219,9 +219,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = select_column_list_data_t; @@ -234,12 +234,7 @@ namespace sqlpp { return t.selected_columns; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_selected_columns_t>::type; @@ -368,9 +363,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -383,12 +378,7 @@ namespace sqlpp { return t.no_selected_columns; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 71461aba..66c6131c 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -104,9 +104,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = select_flag_list_data_t; @@ -119,12 +119,7 @@ namespace sqlpp { return t.select_flags; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = consistent_t; }; @@ -145,9 +140,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -160,11 +155,7 @@ namespace sqlpp { return t.no_select_flags; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index 13b8bb20..824ed892 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -74,9 +74,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = single_table_data_t; @@ -89,12 +89,7 @@ namespace sqlpp { return t.from; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = consistent_t; }; @@ -116,9 +111,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -131,11 +126,7 @@ namespace sqlpp { return t.no_from; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template using _new_statement_t = new_statement; diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 1a6adf64..da6cfb82 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -147,26 +147,24 @@ namespace sqlpp consistent_t, assert_no_unknown_tables_t>::type; using _parameter_check = typename std::conditional::value == 0, consistent_t, assert_no_parameters_t>::type; - - using _run_check = detail::get_first_if::_consistency_check..., _table_check>; - using _prepare_check = detail::get_first_if::_consistency_check..., _table_check>; }; } - template + template struct statement_t: - public Policies::template _member_t>..., + public Policies::template _base_t>..., public expression_operators, value_type_of>>, - public detail::statement_policies_t::_result_methods_t, - public Policies::template _methods_t>... + public detail::statement_policies_t::_result_methods_t { using _policies_t = typename detail::statement_policies_t; - using _run_check = typename _policies_t::_run_check; - using _prepare_check = typename _policies_t::_prepare_check; + + using _run_check = detail::get_first_if::_consistency_check..., + typename _policies_t::_table_check>; + using _prepare_check = detail::get_first_if::_consistency_check..., + typename _policies_t::_table_check>; using _result_type_provider = typename _policies_t::_result_type_provider; template @@ -190,11 +188,10 @@ namespace sqlpp template statement_t(Statement statement, Term term): - Policies::template _member_t<_policies_t>{ + Policies::template _base_t<_policies_t>{ typename Policies::template _impl_t<_policies_t>{ - detail::pick_arg>(statement, term) + detail::pick_arg>(statement, term) }}... - //Policies::template _member_t<_policies_t>{{detail::pick_arg>(statement, term)}}... {} statement_t(const statement_t& r) = default; @@ -238,13 +235,13 @@ namespace sqlpp struct serializer_t> { using P = detail::statement_policies_t; - using _serialize_check = serialize_check_of::_data_t...>; + using _serialize_check = serialize_check_of::_data_t...>; using T = statement_t; static Context& _(const T& t, Context& context) { using swallow = int[]; - (void) swallow{(serialize(static_cast&>(t)()._data, context), 0)...}; + (void) swallow{(serialize(static_cast&>(t)()._data, context), 0)...}; return context; } @@ -266,9 +263,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = NameData; @@ -281,12 +278,7 @@ namespace sqlpp { return t.statement_name; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = consistent_t; }; }; diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index e32b2400..722ac288 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -117,9 +117,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = update_list_data_t; @@ -132,12 +132,7 @@ namespace sqlpp { return t.assignments; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_update_assignments_t>::type; @@ -170,9 +165,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -185,11 +180,7 @@ namespace sqlpp { return t.no_assignments; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index e743e0ae..4221d4eb 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -96,9 +96,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = using_data_t; @@ -111,12 +111,7 @@ namespace sqlpp { return t.using_; } - }; - // Additional methods for the statement - template - struct _methods_t - { // FIXME: Maybe check for unused tables, similar to from using _consistency_check = consistent_t; }; @@ -138,9 +133,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -153,11 +148,7 @@ namespace sqlpp { return t.no_using; } - }; - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index c518b5af..a0afdfdb 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -120,9 +120,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = where_data_t; @@ -135,12 +135,7 @@ namespace sqlpp { return t.where; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = typename std::conditional::value, consistent_t, assert_no_unknown_tables_in_where_t>::type; @@ -170,9 +165,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = where_data_t; @@ -185,12 +180,7 @@ namespace sqlpp { return t.where; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _consistency_check = consistent_t; }; @@ -224,9 +214,9 @@ namespace sqlpp _data_t _data; }; - // Member template for adding the named member to a statement + // Base template to be inherited by the statement template - struct _member_t + struct _base_t { using _data_t = no_data_t; @@ -239,12 +229,7 @@ namespace sqlpp { return t.no_where; } - }; - // Additional methods for the statement - template - struct _methods_t - { using _database_t = typename Policies::_database_t; template using _new_statement_t = new_statement; From 213080f58bb4115386cc7095217e9d1aacfe0acc Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 29 Nov 2014 12:32:21 +0100 Subject: [PATCH 040/105] Fixed prepare in MockDb --- tests/MockDb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/MockDb.h b/tests/MockDb.h index 567b24aa..2e411d4f 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -171,22 +171,22 @@ struct MockDbT: public sqlpp::connection using _prepared_statement_t = std::nullptr_t; template - auto prepare(const T& t, const std::true_type&) -> decltype(t._prepare(*this)) + auto _prepare(const T& t, const std::true_type&) -> decltype(t._prepare(*this)) { return t._prepare(*this); } template - auto prepare(const T& t, const std::false_type&) -> decltype(t._prepare(*this)); + auto _prepare(const T& t, const std::false_type&) -> decltype(t._prepare(*this)); template auto prepare(const T& t) -> decltype(t._prepare(*this)) { sqlpp::prepare_check_t::_(); sqlpp::serialize_check_t<_serializer_context_t, T>::_(); - using _ok = sqlpp::detail::all_t::type::value, + using _ok = sqlpp::detail::all_t::type::value, sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>; - return t._prepare(*this); + return _prepare(t, _ok{}); } From 9110f6653a0295876902a0f2f112d6067bbdd52b Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 29 Nov 2014 14:02:24 +0100 Subject: [PATCH 041/105] Reduced error messages for several clauses --- include/sqlpp11/extra_tables.h | 44 +++++++++++++++++++--------- include/sqlpp11/from.h | 2 +- include/sqlpp11/into.h | 38 +++++++++++++++++------- include/sqlpp11/limit.h | 29 ++++++++++++++----- include/sqlpp11/offset.h | 27 ++++++++++++++--- include/sqlpp11/single_table.h | 28 ++++++++++++++---- include/sqlpp11/update.h | 8 ++--- include/sqlpp11/where.h | 53 ++++++++++++++++++++++++---------- 8 files changed, 169 insertions(+), 60 deletions(-) diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index 28d17f5b..18d74a9b 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -62,12 +62,6 @@ namespace sqlpp using _tags = detail::type_set<>; }; - // FIXME: extra_tables must not require tables! - - static_assert(sizeof...(Tables), "at least one table or join argument required in extra_tables()"); - static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in extra_tables()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not a table or join in extra_tables()"); - // Data using _data_t = extra_tables_data_t; @@ -130,17 +124,41 @@ namespace sqlpp return t.no_extra_tables; } - template - using _new_statement_t = new_statement; + template + using _new_statement_t = new_statement_t; + + template + using _check = detail::all_t::value...>; using _consistency_check = consistent_t; - template - auto extra_tables(Args...) const - -> _new_statement_t> + template + auto extra_tables(Tables... tables) const + -> _new_statement_t<_check, extra_tables_t> { -#warning: need to move static asserts - return { static_cast&>(*this), extra_tables_data_t{} }; + static_assert(_check::value, "at least one argument is not a table or join in extra_tables()"); + + return _extra_tables_impl(_check{}, tables...); + } + + private: + template + auto _extra_tables_impl(const std::false_type&, Tables... tables) const + -> bad_statement; + + template + auto _extra_tables_impl(const std::true_type&, Tables...) const + -> _new_statement_t> + { + static_assert(required_tables_of>::size::value == 0, "at least one table depends on another table in extra_tables()"); + + static constexpr std::size_t _number_of_tables = detail::sum(provided_tables_of::size::value...); + using _unique_tables = detail::make_joined_set_t...>; + using _unique_table_names = detail::transform_set_t; + static_assert(_number_of_tables == _unique_tables::size::value, "at least one duplicate table detected in extra_tables()"); + static_assert(_number_of_tables == _unique_table_names::size::value, "at least one duplicate table name detected in extra_tables()"); + + return { static_cast&>(*this), extra_tables_data_t{} }; } }; }; diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index a821c001..f5a11ded 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -189,7 +189,7 @@ namespace sqlpp auto _from_impl(const std::true_type&, Tables... tables) const -> _new_statement_t> { - static_assert(required_tables_of>::size::value == 0, "at least one table depends on another table"); + static_assert(required_tables_of>::size::value == 0, "at least one table depends on another table in from()"); static constexpr std::size_t _number_of_tables = detail::sum(provided_tables_of::size::value...); using _unique_tables = detail::make_joined_set_t...>; diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index d4a19928..57fe4710 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -61,9 +61,6 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits
; - static_assert(is_table_t
::value, "argument has to be a table"); - static_assert(required_tables_of
::size::value == 0, "table depends on another table"); - using _data_t = into_data_t; struct _name_t {}; @@ -140,16 +137,35 @@ namespace sqlpp } using _database_t = typename Policies::_database_t; + template - using _new_statement_t = new_statement; + using _check = detail::all_t::value>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = assert_into_t; - template - auto into(Args... args) const - -> _new_statement_t> + template + auto into(Table table) const + -> _new_statement_t<_check
, into_t> { - return { static_cast&>(*this), into_data_t{args...} }; + static_assert(_check
::value, "argument is not a table in into()"); + return _into_impl(_check
{}, table); + } + + private: + template + auto _into_impl(const std::false_type&, Table table) const + -> bad_statement; + + template + auto _into_impl(const std::true_type&, Table table) const + -> _new_statement_t> + { + static_assert(required_tables_of>::size::value == 0, "argument depends on another table in into()"); + + return { static_cast&>(*this), into_data_t{table} }; } }; }; @@ -169,10 +185,10 @@ namespace sqlpp } }; - template - auto into(T&&... t) -> decltype(statement_t().into(std::forward(t)...)) + template + auto into(T&& t) -> decltype(statement_t().into(std::forward(t))) { - return statement_t().into(std::forward(t)...); + return statement_t().into(std::forward(t)); } } diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 33fa840f..050da15c 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -57,8 +57,6 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - static_assert(is_integral_t::value, "limit requires an integral value or integral parameter"); - // Data using _data_t = limit_data_t; @@ -134,6 +132,7 @@ namespace sqlpp { // FIXME: Make sure that Limit does not require external tables? Need to read up on SQL using arg_t = wrap_operand_t; + static_assert(is_integral_t::value, "limit requires an integral value or integral parameter"); _data._value = arg_t{value}; _data._initialized = true; } @@ -195,23 +194,39 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _new_statement_t = new_statement; + using _check = is_integral_t>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto limit(Arg arg) const - -> _new_statement_t>> + -> _new_statement_t<_check, limit_t>> { - return { static_cast&>(*this), limit_data_t>{{arg}} }; + static_assert(_check::value, "limit requires an integral value or integral parameter"); + return _limit_impl(_check{}, wrap_operand_t{arg}); } auto dynamic_limit() const - -> _new_statement_t> + -> _new_statement_t> { - static_assert(not std::is_same<_database_t, void>::value, "dynamic_limit must not be called in a static statement"); return { static_cast&>(*this), dynamic_limit_data_t<_database_t>{} }; } + + private: + template + auto _limit_impl(const std::false_type&, Arg arg) const + -> bad_statement; + + template + auto _limit_impl(const std::true_type&, Arg arg) const + -> _new_statement_t> + { + return { static_cast&>(*this), limit_data_t{arg} }; + } + }; }; diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index 44ddc69d..0b3253a2 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -134,6 +134,7 @@ namespace sqlpp { // FIXME: Make sure that Offset does not require external tables? Need to read up on SQL using arg_t = wrap_operand_t; + static_assert(is_integral_t::value, "offset requires an integral value or integral parameter"); _data._value = arg_t{value}; _data._initialized = true; } @@ -205,24 +206,42 @@ namespace sqlpp } using _database_t = typename Policies::_database_t; + template - using _new_statement_t = new_statement; + using _check = is_integral_t>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; template auto offset(Arg arg) const - -> _new_statement_t>> + -> _new_statement_t<_check, offset_t>> { - return { static_cast&>(*this), offset_data_t>{{arg}} }; + static_assert(_check::value, "offset requires an integral value or integral parameter"); + return _offset_impl(_check{}, wrap_operand_t{arg}); } auto dynamic_offset() const - -> _new_statement_t> + -> _new_statement_t> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_offset must not be called in a static statement"); return { static_cast&>(*this), dynamic_offset_data_t<_database_t>{} }; } + + private: + template + auto _offset_impl(const std::false_type&, Arg arg) const + -> bad_statement; + + template + auto _offset_impl(const std::true_type&, Arg arg) const + -> _new_statement_t> + { + return { static_cast&>(*this), offset_data_t{arg} }; + } + }; }; diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index 824ed892..867f1ed3 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -129,15 +129,33 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _new_statement_t = new_statement; + using _check = detail::all_t::value>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = consistent_t; - template - auto from(Args... args) const - -> _new_statement_t> + template + auto single_table(Table table) const + -> _new_statement_t<_check
, single_table_t> { - return { static_cast&>(*this), single_table_data_t{args...} }; + static_assert(_check
::value, "argument is not a table in single_table()"); + return _single_table_impl(_check
{}, table); + } + + private: + template + auto _single_table_impl(const std::false_type&, Table table) const + -> bad_statement; + + template + auto _single_table_impl(const std::true_type&, Table table) const + -> _new_statement_t> + { + static_assert(required_tables_of>::size::value == 0, "argument depends on another table in single_table()"); + + return { static_cast&>(*this), single_table_data_t{table} }; } }; }; diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index 09ee8a5d..7e1058f6 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -112,17 +112,17 @@ namespace sqlpp template constexpr auto update(Table table) - -> decltype(blank_update_t().from(table)) + -> decltype(blank_update_t().single_table(table)) { - return { blank_update_t().from(table) }; + return { blank_update_t().single_table(table) }; } template constexpr auto dynamic_update(const Database&, Table table) - -> decltype(blank_update_t().from(table)) + -> decltype(blank_update_t().single_table(table)) { static_assert(std::is_base_of::value, "Invalid database parameter"); - return { blank_update_t().from(table) }; + return { blank_update_t().single_table(table) }; } } diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index a0afdfdb..6b4f8490 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -75,10 +75,6 @@ namespace sqlpp using _is_dynamic = is_database; - static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression argument required in where()"); - static_assert(detail::none_t::value...>::value, "at least one argument is an assignment in where()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not valid expression in where()"); - // Data using _data_t = where_data_t; @@ -231,28 +227,55 @@ namespace sqlpp } using _database_t = typename Policies::_database_t; - template - using _new_statement_t = new_statement; + + template + using _check = detail::all_t::value...>; + + template + using _new_statement_t = new_statement_t; using _consistency_check = typename std::conditional< WhereRequired and (Policies::_all_provided_tables::size::value > 0), assert_where_t, consistent_t>::type; - template - auto where(Args... args) const - -> _new_statement_t> + auto where(bool b) const + -> _new_statement_t> { - return { static_cast&>(*this), where_data_t{args...} }; + return { static_cast&>(*this), where_data_t{b} }; } - template - auto dynamic_where(Args... args) const - -> _new_statement_t> + template + auto where(Expressions... expressions) const + -> _new_statement_t<_check, where_t> { - static_assert(not std::is_same<_database_t, void>::value, "dynamic_where must not be called in a static statement"); - return { static_cast&>(*this), where_data_t<_database_t, Args...>{args...} }; + static_assert(_check::value, "at least one argument is not an expression in where()"); + static_assert(sizeof...(Expressions), "at least one expression argument required in where()"); + + return _where_impl(_check{}, expressions...); } + + template + auto dynamic_where(Expressions... expressions) const + -> _new_statement_t<_check, where_t<_database_t, Expressions...>> + { + static_assert(_check::value, "at least one argument is not an expression in where()"); + static_assert(not std::is_same<_database_t, void>::value, "dynamic_where must not be called in a static statement"); + return _where_impl<_database_t>(_check{}, expressions...); + } + + private: + template + auto _where_impl(const std::false_type&, Expressions... expressions) const + -> bad_statement; + + template + auto _where_impl(const std::true_type&, Expressions... expressions) const + -> _new_statement_t> + { + return { static_cast&>(*this), where_data_t<_database_t, Expressions...>{expressions...} }; + } + }; }; From f02a9ce3d0e5d176c5e0391d2810a51f75af0cb3 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 29 Nov 2014 14:29:54 +0100 Subject: [PATCH 042/105] Moved logic functions from detail into logic namespace --- include/sqlpp11/basic_expression_operators.h | 6 +++--- include/sqlpp11/concat.h | 4 ++-- include/sqlpp11/detail/type_set.h | 6 +++--- include/sqlpp11/extra_tables.h | 4 ++-- include/sqlpp11/field_spec.h | 2 +- include/sqlpp11/from.h | 6 +++--- include/sqlpp11/group_by.h | 6 +++--- include/sqlpp11/having.h | 6 +++--- include/sqlpp11/insert_value_list.h | 20 ++++++++++---------- include/sqlpp11/into.h | 2 +- include/sqlpp11/join.h | 2 +- include/sqlpp11/{detail => }/logic.h | 2 +- include/sqlpp11/multi_column.h | 6 +++--- include/sqlpp11/on.h | 4 ++-- include/sqlpp11/order_by.h | 6 +++--- include/sqlpp11/select_column_list.h | 6 +++--- include/sqlpp11/select_flag_list.h | 4 ++-- include/sqlpp11/single_table.h | 2 +- include/sqlpp11/statement.h | 8 ++++---- include/sqlpp11/type_traits.h | 2 +- include/sqlpp11/update_list.h | 8 ++++---- include/sqlpp11/using.h | 4 ++-- include/sqlpp11/where.h | 6 +++--- tests/MockDb.h | 4 ++-- 24 files changed, 63 insertions(+), 63 deletions(-) rename include/sqlpp11/{detail => }/logic.h (99%) diff --git a/include/sqlpp11/basic_expression_operators.h b/include/sqlpp11/basic_expression_operators.h index e3bfb5e4..ac99ede1 100644 --- a/include/sqlpp11/basic_expression_operators.h +++ b/include/sqlpp11/basic_expression_operators.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -130,14 +130,14 @@ namespace sqlpp template in_t...> in(T... t) const { - static_assert(detail::all_t<_is_valid_comparison_operand>::value...>::value, "at least one operand of in() is not valid"); + static_assert(logic::all_t<_is_valid_comparison_operand>::value...>::value, "at least one operand of in() is not valid"); return { *static_cast(this), wrap_operand_t{t}... }; } template in_t...> not_in(T... t) const { - static_assert(detail::all_t<_is_valid_comparison_operand>::value...>::value, "at least one operand of in() is not valid"); + static_assert(logic::all_t<_is_valid_comparison_operand>::value...>::value, "at least one operand of in() is not valid"); return { *static_cast(this), wrap_operand_t{t}... }; } }; diff --git a/include/sqlpp11/concat.h b/include/sqlpp11/concat.h index 1dbb1c10..0c4fa6c1 100644 --- a/include/sqlpp11/concat.h +++ b/include/sqlpp11/concat.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -44,7 +44,7 @@ namespace sqlpp using _recursive_traits = make_recursive_traits; static_assert(sizeof...(Args) > 0, "concat requires two arguments at least"); - static_assert(detail::all_t::value, is_text_t::value...>::value, "at least one non-text argument detected in concat()"); + static_assert(logic::all_t::value, is_text_t::value...>::value, "at least one non-text argument detected in concat()"); struct _name_t { static constexpr const char* _get_name() { return "CONCAT"; } diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h index 3b4d48d6..5e1be6c0 100644 --- a/include/sqlpp11/detail/type_set.h +++ b/include/sqlpp11/detail/type_set.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace sqlpp { @@ -81,7 +81,7 @@ namespace sqlpp template struct is_element_of> { - static constexpr bool value = any_t::value...>::value; + static constexpr bool value = ::sqlpp::logic::any_t::value...>::value; }; template @@ -223,7 +223,7 @@ namespace sqlpp struct make_intersect_set, type_set> { template - using is_in_both = all_t>::value, is_element_of>::value>; + using is_in_both = ::sqlpp::logic::all_t>::value, is_element_of>::value>; using type = make_type_set_if_t; }; diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index 18d74a9b..884e1946 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -28,7 +28,7 @@ #define SQLPP_EXTRA_TABLES_H #include -#include +#include #include namespace sqlpp @@ -128,7 +128,7 @@ namespace sqlpp using _new_statement_t = new_statement_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; using _consistency_check = consistent_t; diff --git a/include/sqlpp11/field_spec.h b/include/sqlpp11/field_spec.h index ee2ae33c..c745545f 100644 --- a/include/sqlpp11/field_spec.h +++ b/include/sqlpp11/field_spec.h @@ -58,7 +58,7 @@ namespace sqlpp using type = field_spec_t, - detail::any_t<_can_be_null, _depends_on_outer_table>::value, + logic::any_t<_can_be_null, _depends_on_outer_table>::value, null_is_trivial_value_t::value>; }; diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index f5a11ded..d5c0cf6f 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -81,7 +81,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_table_t
::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_table_t
::value, _serialize_check::type::value>; _add_impl(table, ok()); // dispatch to prevent compile messages after the static_assert } @@ -155,7 +155,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 9b1e4234..a8f73185 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -97,7 +97,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } @@ -172,7 +172,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index 28812576..c26cfa6f 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -96,7 +96,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } @@ -172,7 +172,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 31893849..a0763799 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -28,7 +28,7 @@ #define SQLPP_INSERT_VALUE_LIST_H #include -#include +#include #include #include #include @@ -167,7 +167,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t< + using ok = logic::all_t< _is_dynamic::value, is_assignment_t::value, _serialize_check::type::value>; @@ -260,13 +260,13 @@ namespace sqlpp template void add(Assignments... assignments) { - static_assert(detail::all_t::value...>::value, "add_values() arguments have to be assignments"); + static_assert(logic::all_t::value...>::value, "add_values() arguments have to be assignments"); using _arg_value_tuple = std::tuple>...>; using _args_correct = std::is_same<_arg_value_tuple, _value_tuple_t>; static_assert(_args_correct::value, "add_values() arguments do not match columns() arguments"); - using ok = detail::all_t< - detail::all_t::value...>::value, + using ok = logic::all_t< + logic::all_t::value...>::value, _args_correct::value>; _add_impl(ok(), assignments...); // dispatch to prevent compile messages after the static_assert @@ -353,10 +353,10 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _column_check = detail::all_t::value...>; + using _column_check = logic::all_t::value...>; template - using _assignment_check = detail::all_t::value...>; + using _assignment_check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; @@ -373,7 +373,7 @@ namespace sqlpp auto columns(Columns... columns) const -> _new_statement_t<_column_check, column_list_t> { - static_assert(detail::all_t::value...>::value, "at least one argument is not a column in columns()"); + static_assert(logic::all_t::value...>::value, "at least one argument is not a column in columns()"); static_assert(sizeof...(Columns), "at least one column required in columns()"); return _columns_impl(_column_check{}, columns...); @@ -408,7 +408,7 @@ namespace sqlpp -> _new_statement_t> { static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in columns()"); - static_assert(detail::none_t::value...>::value, "at least one column argument has a must_not_insert tag in its definition"); + static_assert(logic::none_t::value...>::value, "at least one column argument has a must_not_insert tag in its definition"); using _column_required_tables = detail::make_joined_set_t...>; static_assert(_column_required_tables::size::value == 1, "columns() contains columns from several tables"); @@ -426,7 +426,7 @@ namespace sqlpp -> _new_statement_t> { static_assert(not detail::has_duplicates...>::value, "at least one duplicate column detected in set()"); - static_assert(detail::none_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()"); + static_assert(logic::none_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()"); using _column_required_tables = detail::make_joined_set_t>...>; static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true, "set() contains assignments for columns from several tables"); diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index 57fe4710..bcf4055a 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -139,7 +139,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value>; + using _check = logic::all_t::value>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index f1097468..99dbcdd0 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -94,7 +94,7 @@ namespace sqlpp -> set_on_t> { static_assert(is_noop::value, "cannot call on() twice for a single join()"); - static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in on()"); + static_assert(logic::all_t::value...>::value, "at least one argument is not an expression in on()"); return { _lhs, _rhs, diff --git a/include/sqlpp11/detail/logic.h b/include/sqlpp11/logic.h similarity index 99% rename from include/sqlpp11/detail/logic.h rename to include/sqlpp11/logic.h index 11366ae9..a70d4110 100644 --- a/include/sqlpp11/detail/logic.h +++ b/include/sqlpp11/logic.h @@ -32,7 +32,7 @@ namespace sqlpp { - namespace detail + namespace logic { template struct logic_helper; diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index dce7dce2..24d300c4 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -28,7 +28,7 @@ #define SQLPP_MULTI_COLUMN_H #include -#include +#include #include #include @@ -44,7 +44,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - static_assert(detail::all_t::value...>::value, "multi_column parameters need to be named expressions"); + static_assert(logic::all_t::value...>::value, "multi_column parameters need to be named expressions"); multi_column_t(std::tuple columns): _columns(columns) @@ -75,7 +75,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - static_assert(detail::all_t::value...>::value, "multi_column parameters need to be named expressions"); + static_assert(logic::all_t::value...>::value, "multi_column parameters need to be named expressions"); using _name_t = typename AliasProvider::_name_t; diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index 43bd7c80..4a23595d 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -52,7 +52,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expr, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index 87383943..daf50517 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include namespace sqlpp @@ -97,7 +97,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_sort_order_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_sort_order_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } @@ -172,7 +172,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index d4244cf8..84341eb4 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -196,7 +196,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t< + using ok = logic::all_t< _is_dynamic::value, is_selectable_t::value, _serialize_check::type::value @@ -284,7 +284,7 @@ namespace sqlpp _alias_t as(const AliasProvider& aliasProvider) const { static_assert(_statement_t::_can_be_used_as_table(), "statement cannot be used as table, e.g. due to missing tables"); - static_assert(detail::none_t::value...>::value, "cannot use multi-columns in sub selects"); + static_assert(logic::none_t::value...>::value, "cannot use multi-columns in sub selects"); return _table_t(_get_statement()).as(aliasProvider); } @@ -382,7 +382,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t<(is_selectable_t::value or is_multi_column_t::value)...>; + using _check = logic::all_t<(is_selectable_t::value or is_multi_column_t::value)...>; template static constexpr auto _check_tuple(std::tuple) -> _check diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 66c6131c..d4b9fdef 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -86,7 +86,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_select_flag_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_select_flag_t::value, _serialize_check::type::value>; _add_impl(flag, ok()); // dispatch to prevent compile messages after the static_assert } @@ -159,7 +159,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index 867f1ed3..1b8839a9 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -129,7 +129,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value>; + using _check = logic::all_t::value>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index da6cfb82..8950a6a7 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -117,12 +117,12 @@ namespace sqlpp } using _value_type = typename std::conditional< - detail::none_t::value...>::value, + logic::none_t::value...>::value, value_type_of<_result_type_provider>, no_value_t // if a required statement part is missing (e.g. columns in a select), then the statement cannot be used as a value >::type; - using _can_be_null = detail::any_t< + using _can_be_null = logic::any_t< can_be_null_t<_result_type_provider>::value, detail::make_intersect_set_t< required_tables_of<_result_type_provider>, @@ -172,10 +172,10 @@ namespace sqlpp using _traits = make_traits, tag::is_statement, - tag_if::value...>::value>, + tag_if::value...>::value>, tag_if::value>, tag_if::value>, - tag_if::value>::value>, + tag_if::value>::value>, tag::requires_braces>; using _recursive_traits = typename _policies_t::_recursive_traits; using _used_outer_tables = typename _policies_t::_all_provided_outer_tables; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 7c2db471..ec1510bb 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -109,7 +109,7 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(is_integral); SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point); template - using is_numeric_t = detail::any_t< + using is_numeric_t = logic::any_t< detail::is_element_of::value, detail::is_element_of::value>; SQLPP_VALUE_TRAIT_GENERATOR(is_text); diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 722ac288..ba5ddc8d 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -91,12 +91,12 @@ namespace sqlpp static_assert(is_assignment_t::value, "invalid assignment argument in add()"); using _assigned_columns = detail::make_type_set_t...>; static_assert(not detail::is_element_of, _assigned_columns>::value, "Must not assign value to column twice"); - static_assert(detail::not_t>::value, "add() argument must not be updated"); + static_assert(logic::not_t>::value, "add() argument must not be updated"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "assignment uses tables unknown to this statement in add()"); using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t< + using ok = logic::all_t< _is_dynamic::value, is_assignment_t::value, _serialize_check::type::value>; @@ -184,7 +184,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; @@ -221,7 +221,7 @@ namespace sqlpp -> _new_statement_t> { static_assert(not detail::has_duplicates...>::value, "at least one duplicate column detected in set()"); - static_assert(detail::none_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()"); + static_assert(logic::none_t>::value...>::value, "at least one assignment is prohibited by its column definition in set()"); using _column_required_tables = detail::make_joined_set_t>...>; static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true, "set() contains assignments for columns from more than one table"); diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index 4221d4eb..cf1bdea8 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -77,7 +77,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_table_t
::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_table_t
::value, _serialize_check::type::value>; _add_impl(table, ok()); // dispatch to prevent compile messages after the static_assert } @@ -152,7 +152,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 6b4f8490..161da725 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -97,7 +97,7 @@ namespace sqlpp using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = detail::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } @@ -229,7 +229,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = detail::all_t::value...>; + using _check = logic::all_t::value...>; template using _new_statement_t = new_statement_t; diff --git a/tests/MockDb.h b/tests/MockDb.h index 2e411d4f..7d200eb1 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -120,7 +120,7 @@ struct MockDbT: public sqlpp::connection { sqlpp::run_check_t::_(); sqlpp::serialize_check_t<_serializer_context_t, T>::_(); - using _ok = sqlpp::detail::all_t::type::value, + using _ok = sqlpp::logic::all_t::type::value, sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>; return _run(t, _ok{}); } @@ -184,7 +184,7 @@ struct MockDbT: public sqlpp::connection { sqlpp::prepare_check_t::_(); sqlpp::serialize_check_t<_serializer_context_t, T>::_(); - using _ok = sqlpp::detail::all_t::type::value, + using _ok = sqlpp::logic::all_t::type::value, sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>; return _prepare(t, _ok{}); } From d34c22ca5ac06cd2fce7594e9fe8d26f64ff283a Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 29 Nov 2014 17:36:09 +0100 Subject: [PATCH 043/105] Simplified serializer a bit --- include/sqlpp11/serializer.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/sqlpp11/serializer.h b/include/sqlpp11/serializer.h index 46261e0e..78280a6e 100644 --- a/include/sqlpp11/serializer.h +++ b/include/sqlpp11/serializer.h @@ -31,7 +31,6 @@ namespace sqlpp { - template struct assert_serializer_specialization_t { using type = std::false_type; @@ -46,7 +45,7 @@ namespace sqlpp template struct serializer_t { - using _serialize_check = assert_serializer_specialization_t; + using _serialize_check = assert_serializer_specialization_t; static void _(const T& t, Context& context) { From 74cafe35dd75a1ac994e538e6e6583954a9f5eed Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 30 Nov 2014 19:40:34 +0100 Subject: [PATCH 044/105] We now have unique name representations per name Before this, there could be multiple classes representing multiple id columns. Now there is one class representing ALL the name "id". Very important for analyzing potential name clashes. --- examples/Sample.h | 41 +++++---- include/sqlpp11/alias.h | 4 +- include/sqlpp11/alias_provider.h | 8 +- include/sqlpp11/any.h | 6 +- include/sqlpp11/avg.h | 6 +- include/sqlpp11/basic_expression_operators.h | 8 +- include/sqlpp11/char_sequence.h | 56 ++++++++++++ include/sqlpp11/column.h | 9 +- include/sqlpp11/concat.h | 6 +- include/sqlpp11/count.h | 6 +- include/sqlpp11/eval.h | 2 +- include/sqlpp11/exists.h | 6 +- include/sqlpp11/field_spec.h | 4 +- include/sqlpp11/from.h | 2 +- include/sqlpp11/functions.h | 4 +- include/sqlpp11/in.h | 21 +++-- include/sqlpp11/in_fwd.h | 4 +- include/sqlpp11/insert.h | 2 +- include/sqlpp11/into.h | 2 +- include/sqlpp11/is_not_null.h | 85 +++++++++++++++++ include/sqlpp11/is_null.h | 24 ++--- include/sqlpp11/is_null_fwd.h | 4 +- include/sqlpp11/like.h | 6 +- include/sqlpp11/max.h | 6 +- include/sqlpp11/min.h | 6 +- include/sqlpp11/multi_column.h | 2 +- include/sqlpp11/named_interpretable.h | 3 +- include/sqlpp11/noop.h | 2 +- include/sqlpp11/not_in.h | 96 ++++++++++++++++++++ include/sqlpp11/remove.h | 2 +- include/sqlpp11/result_row.h | 2 +- include/sqlpp11/select_column_list.h | 16 ++-- include/sqlpp11/select_pseudo_table.h | 2 +- include/sqlpp11/simple_column.h | 5 +- include/sqlpp11/single_table.h | 2 +- include/sqlpp11/some.h | 6 +- include/sqlpp11/statement.h | 2 +- include/sqlpp11/sum.h | 6 +- include/sqlpp11/table.h | 2 +- include/sqlpp11/table_alias.h | 4 +- include/sqlpp11/type_traits.h | 7 +- include/sqlpp11/update.h | 2 +- include/sqlpp11/verbatim_table.h | 10 +- scripts/ddl2cpp | 12 ++- tests/Sample.h | 46 ++++++---- tests/SelectTest.cpp | 1 - 46 files changed, 425 insertions(+), 133 deletions(-) create mode 100644 include/sqlpp11/char_sequence.h create mode 100644 include/sqlpp11/is_not_null.h create mode 100644 include/sqlpp11/not_in.h diff --git a/examples/Sample.h b/examples/Sample.h index 43aa3dc2..01e7d92d 100644 --- a/examples/Sample.h +++ b/examples/Sample.h @@ -3,6 +3,7 @@ #include #include +#include namespace test { @@ -10,9 +11,10 @@ namespace test { struct Id { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "id"; } + static constexpr const char _literal[] = "id"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -25,9 +27,10 @@ namespace test }; struct Name { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "name"; } + static constexpr const char _literal[] = "name"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -40,9 +43,10 @@ namespace test }; struct Feature { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "feature"; } + static constexpr const char _literal[] = "feature"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -60,9 +64,10 @@ namespace test TabPerson_::Name, TabPerson_::Feature> { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "tab_person"; } + static constexpr const char _literal[] = "tab_person"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -76,9 +81,10 @@ namespace test { struct Id { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "id"; } + static constexpr const char _literal[] = "id"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -91,9 +97,10 @@ namespace test }; struct Name { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "name"; } + static constexpr const char _literal[] = "name"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -106,9 +113,10 @@ namespace test }; struct Fatal { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "fatal"; } + static constexpr const char _literal[] = "fatal"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -126,9 +134,10 @@ namespace test TabFeature_::Name, TabFeature_::Fatal> { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "tab_feature"; } + static constexpr const char _literal[] = "tab_feature"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { diff --git a/include/sqlpp11/alias.h b/include/sqlpp11/alias.h index 22c49dcf..2f5b9c1f 100644 --- a/include/sqlpp11/alias.h +++ b/include/sqlpp11/alias.h @@ -41,7 +41,7 @@ namespace sqlpp static_assert(is_expression_t::value, "invalid argument for an expression alias"); static_assert(not is_alias_t::value, "cannot create an alias of an alias"); - using _name_t = typename AliasProvider::_name_t; + using _alias_t = typename AliasProvider::_alias_t; Expression _expression; }; @@ -57,7 +57,7 @@ namespace sqlpp context << '('; serialize(t._expression, context); context << ") AS "; - context << T::_name_t::_get_name(); + context << name_of::char_ptr(); return context; } }; diff --git a/include/sqlpp11/alias_provider.h b/include/sqlpp11/alias_provider.h index 78dcf1e3..266ec51e 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -28,13 +28,15 @@ #define SQLPP_ALIAS_PROVIDER_H #include +#include #define SQLPP_ALIAS_PROVIDER(name) \ struct name##_t\ {\ - struct _name_t\ + struct _alias_t\ {\ - static constexpr const char* _get_name() { return #name; }\ + static constexpr const char _literal[] = #name;\ + using _name_t = sqlpp::make_char_sequence;\ template\ struct _member_t\ {\ @@ -55,7 +57,7 @@ namespace sqlpp }; template - struct is_alias_provider_t>::value, void>::type> + struct is_alias_provider_t>::value, void>::type> { static constexpr bool value = true; }; diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index 2cc6d8a8..2941718f 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -28,6 +28,7 @@ #define SQLPP_ANY_H #include +#include #include namespace sqlpp @@ -38,9 +39,10 @@ namespace sqlpp using _traits = make_traits, tag::is_multi_expression>; using _recursive_traits = make_recursive_traits::value, "exists() requires a select expression as argument"); - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "EXISTS"; } + static constexpr const char _literal[] = "exists_"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { diff --git a/include/sqlpp11/field_spec.h b/include/sqlpp11/field_spec.h index c745545f..16540042 100644 --- a/include/sqlpp11/field_spec.h +++ b/include/sqlpp11/field_spec.h @@ -40,7 +40,7 @@ namespace sqlpp >; using _recursive_traits = make_recursive_traits<>; - using _name_t = NameType; + using _alias_t = NameType; }; template @@ -56,7 +56,7 @@ namespace sqlpp static constexpr bool _can_be_null = can_be_null_t::value; static constexpr bool _depends_on_outer_table = detail::make_intersect_set_t, typename Select::_used_outer_tables>::size::value > 0; - using type = field_spec_t, logic::any_t<_can_be_null, _depends_on_outer_table>::value, null_is_trivial_value_t::value>; diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index d5c0cf6f..bbe7d939 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -77,7 +77,7 @@ namespace sqlpp static_assert(is_table_t
::value, "invalid table argument in from::add()"); using _known_tables = detail::make_joined_set_t...>; // Hint: Joins contain more than one table using _known_table_names = detail::transform_set_t; - static_assert(not detail::is_element_of::value, "Must not use the same table name twice in from()"); + static_assert(not detail::is_element_of::value, "Must not use the same table name twice in from()"); using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 9172cb81..b31dd741 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -31,7 +31,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -129,7 +131,7 @@ namespace sqlpp template constexpr const char* get_sql_name(const T&) { - return T::_name_t::_get_name(); + return name_of::char_ptr(); } diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index 6726f7b5..613b1158 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -28,26 +28,27 @@ #define SQLPP_IN_H #include +#include #include #include #include namespace sqlpp { - template + template struct in_t: - public expression_operators, boolean>, - public alias_operators> + public expression_operators, boolean>, + public alias_operators> { using _traits = make_traits; using _recursive_traits = make_recursive_traits; - static constexpr bool _inverted = not NotInverted; static_assert(sizeof...(Args) > 0, "in() requires at least one argument"); - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return _inverted ? "NOT IN" : "IN"; } + static constexpr const char _literal[] = "in_"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -70,16 +71,16 @@ namespace sqlpp std::tuple _args; }; - template - struct serializer_t> + template + struct serializer_t> { using _serialize_check = serialize_check_of; - using T = in_t; + using T = in_t; static Context& _(const T& t, Context& context) { serialize(t._operand, context); - context << (t._inverted ? " NOT IN(" : " IN("); + context << " IN("; if (sizeof...(Args) == 1) serialize(std::get<0>(t._args), context); // FIXME: this is a bit of a hack until there is a better overall strategy for using braces // see https://github.com/rbock/sqlpp11/issues/18 diff --git a/include/sqlpp11/in_fwd.h b/include/sqlpp11/in_fwd.h index 3b464307..f35552ef 100644 --- a/include/sqlpp11/in_fwd.h +++ b/include/sqlpp11/in_fwd.h @@ -29,8 +29,10 @@ namespace sqlpp { - template + template struct in_t; + template + struct not_in_t; } diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 9e8b81a4..5aa99a33 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -44,7 +44,7 @@ namespace sqlpp struct insert_t: public statement_name_t { using _traits = make_traits; - struct _name_t {}; + struct _alias_t {}; template struct _result_methods_t diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index bcf4055a..78413be7 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -63,7 +63,7 @@ namespace sqlpp using _data_t = into_data_t; - struct _name_t {}; + struct _alias_t {}; // Member implementation with data and methods template diff --git a/include/sqlpp11/is_not_null.h b/include/sqlpp11/is_not_null.h new file mode 100644 index 00000000..3db4f148 --- /dev/null +++ b/include/sqlpp11/is_not_null.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_IS_NOT_NULL_H +#define SQLPP_IS_NOT_NULL_H + +#include +#include +#include +#include + +namespace sqlpp +{ + template + struct is_not_null_t: + public expression_operators, boolean>, + public alias_operators> + { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits; + + struct _alias_t + { + static constexpr const char _literal[] = "is_not_null_"; + using _name_t = sqlpp::make_char_sequence; + template + struct _member_t + { + T is_not_null; + }; + }; + + is_not_null_t(Operand operand): + _operand(operand) + {} + + is_not_null_t(const is_not_null_t&) = default; + is_not_null_t(is_not_null_t&&) = default; + is_not_null_t& operator=(const is_not_null_t&) = default; + is_not_null_t& operator=(is_not_null_t&&) = default; + ~is_not_null_t() = default; + + Operand _operand; + }; + + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = is_not_null_t; + + static Context& _(const T& t, Context& context) + { + serialize(t._operand, context); + context << " IS NOT NULL"; + return context; + } + }; + +} + +#endif diff --git a/include/sqlpp11/is_null.h b/include/sqlpp11/is_null.h index bca37cf0..f40d7cf5 100644 --- a/include/sqlpp11/is_null.h +++ b/include/sqlpp11/is_null.h @@ -29,27 +29,27 @@ #include #include +#include #include namespace sqlpp { - template + template struct is_null_t: - public expression_operators, boolean>, - public alias_operators> + public expression_operators, boolean>, + public alias_operators> { using _traits = make_traits; using _recursive_traits = make_recursive_traits; - static constexpr bool _inverted = not NotInverted; - - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return _inverted ? "IS NOT NULL" : "IS NULL"; } + static constexpr const char _literal[] = "is_nnull_"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { - T in; + T is_null; }; }; @@ -66,16 +66,16 @@ namespace sqlpp Operand _operand; }; - template - struct serializer_t> + template + struct serializer_t> { using _serialize_check = serialize_check_of; - using T = is_null_t; + using T = is_null_t; static Context& _(const T& t, Context& context) { serialize(t._operand, context); - context << (t._inverted ? " IS NOT NULL" : " IS NULL"); + context << " IS NULL"; return context; } }; diff --git a/include/sqlpp11/is_null_fwd.h b/include/sqlpp11/is_null_fwd.h index 8d53cc01..21db3436 100644 --- a/include/sqlpp11/is_null_fwd.h +++ b/include/sqlpp11/is_null_fwd.h @@ -29,8 +29,10 @@ namespace sqlpp { - template + template struct is_null_t; + template + struct is_not_null_t; } #endif diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index b5bb9101..9ae9940c 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -29,6 +29,7 @@ #include #include +#include #include namespace sqlpp @@ -41,9 +42,10 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "LIKE"; } + static constexpr const char _literal[] = "like_"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { diff --git a/include/sqlpp11/max.h b/include/sqlpp11/max.h index 251d6023..4bba58fc 100644 --- a/include/sqlpp11/max.h +++ b/include/sqlpp11/max.h @@ -28,6 +28,7 @@ #define SQLPP_MAX_H #include +#include namespace sqlpp { @@ -39,9 +40,10 @@ namespace sqlpp using _traits = make_traits, tag::is_expression, tag::is_selectable>; using _recursive_traits = make_recursive_traits; - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "MAX"; } + static constexpr const char _literal[] = "max_"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { diff --git a/include/sqlpp11/min.h b/include/sqlpp11/min.h index 04bb30cf..2077ae4c 100644 --- a/include/sqlpp11/min.h +++ b/include/sqlpp11/min.h @@ -28,6 +28,7 @@ #define SQLPP_MIN_H #include +#include namespace sqlpp { @@ -39,9 +40,10 @@ namespace sqlpp using _traits = make_traits, tag::is_expression, tag::is_selectable>; using _recursive_traits = make_recursive_traits; - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "MIN"; } + static constexpr const char _literal[] = "min_"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index 24d300c4..70dbec66 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -77,7 +77,7 @@ namespace sqlpp static_assert(logic::all_t::value...>::value, "multi_column parameters need to be named expressions"); - using _name_t = typename AliasProvider::_name_t; + using _alias_t = typename AliasProvider::_alias_t; multi_column_alias_t(multi_column_t multi_column): _columns(multi_column._columns) diff --git a/include/sqlpp11/named_interpretable.h b/include/sqlpp11/named_interpretable.h index 3ec6c1ea..6ebacd04 100644 --- a/include/sqlpp11/named_interpretable.h +++ b/include/sqlpp11/named_interpretable.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace sqlpp { @@ -111,7 +112,7 @@ namespace sqlpp std::string _get_name() const { - return T::_name_t::_get_name(); + return name_of::char_ptr(); } T _t; diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index 62f3b7db..dfa2c2ff 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -39,7 +39,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; - struct _name_t {}; + struct _alias_t {}; template struct _result_methods_t diff --git a/include/sqlpp11/not_in.h b/include/sqlpp11/not_in.h new file mode 100644 index 00000000..0aa47547 --- /dev/null +++ b/include/sqlpp11/not_in.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_NOT_IN_H +#define SQLPP_NOT_IN_H + +#include +#include +#include +#include +#include + +namespace sqlpp +{ + template + struct not_in_t: + public expression_operators, boolean>, + public alias_operators> + { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits; + + static_assert(sizeof...(Args) > 0, "not_in() requires at least one argument"); + + struct _alias_t + { + static constexpr const char _literal[] = "not_in_"; + using _name_t = sqlpp::make_char_sequence; + template + struct _member_t + { + T not_in; + }; + }; + + not_in_t(Operand operand, Args... args): + _operand(operand), + _args(args...) + {} + + not_in_t(const not_in_t&) = default; + not_in_t(not_in_t&&) = default; + not_in_t& operator=(const not_in_t&) = default; + not_in_t& operator=(not_in_t&&) = default; + ~not_in_t() = default; + + Operand _operand; + std::tuple _args; + }; + + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = not_in_t; + + static Context& _(const T& t, Context& context) + { + serialize(t._operand, context); + context << " NOT IN("; + if (sizeof...(Args) == 1) + serialize(std::get<0>(t._args), context); // FIXME: this is a bit of a hack until there is a better overall strategy for using braces + // see https://github.com/rbock/sqlpp11/issues/18 + else + interpret_tuple(t._args, ',', context); + context << ')'; + return context; + } + }; + +} + +#endif diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index 8d5f43be..e9337e14 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -44,7 +44,7 @@ namespace sqlpp struct remove_t: public statement_name_t { using _traits = make_traits; - struct _name_t {}; + struct _alias_t {}; template struct _result_methods_t diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 60528ed0..f9e21fcf 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -186,7 +186,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; - struct _name_t {}; + struct _alias_t {}; }; using _field_type = result_field_t; diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 84341eb4..eedf03e3 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -48,14 +48,14 @@ namespace sqlpp struct select_traits { using _traits = make_traits; - struct _name_t {}; + struct _alias_t {}; }; template struct select_traits { using _traits = make_traits, tag::is_select_column_list, tag::is_return_value, tag::is_expression, tag::is_selectable>; - using _name_t = typename Column::_name_t; + using _alias_t = typename Column::_alias_t; }; } @@ -69,7 +69,7 @@ namespace sqlpp template void emplace_back(Expr expr) { - _dynamic_expression_names.push_back(Expr::_name_t::_get_name()); + _dynamic_expression_names.push_back(name_of::char_ptr()); _dynamic_columns.emplace_back(expr); } @@ -166,7 +166,7 @@ namespace sqlpp using _traits = typename detail::select_traits::_traits; using _recursive_traits = make_recursive_traits; - using _name_t = typename detail::select_traits::_name_t; + using _alias_t = typename detail::select_traits::_alias_t; using _is_dynamic = is_database; @@ -191,8 +191,8 @@ namespace sqlpp static_assert(_is_dynamic::value, "selected_columns::add() can only be called for dynamic_column"); static_assert(is_selectable_t::value, "invalid named expression argument in selected_columns::add()"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "named expression uses tables unknown to this statement in selected_columns::add()"); - using column_names = detail::make_type_set_t; - static_assert(not detail::is_element_of::value, "a column of this name is present in the select already"); + using column_names = detail::make_type_set_t; + static_assert(not detail::is_element_of::value, "a column of this name is present in the select already"); using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); @@ -351,7 +351,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; - struct _name_t {}; + struct _alias_t {}; // Data using _data_t = no_data_t; @@ -431,7 +431,7 @@ namespace sqlpp -> _new_statement_t<_check, select_column_list_t> { static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected"); - static_assert(not detail::has_duplicates::value, "at least one duplicate name detected"); + static_assert(not detail::has_duplicates::value, "at least one duplicate name detected"); return { static_cast&>(*this), typename select_column_list_t::_data_t{args} }; } diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 28429e5f..7e50d87a 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -35,7 +35,7 @@ namespace sqlpp template struct select_column_spec_t { - using _name_t = typename NamedExpr::_name_t; + using _alias_t = typename NamedExpr::_alias_t; static constexpr bool _can_be_null = can_be_null_t::value; static constexpr bool _depends_on_outer_table = detail::make_intersect_set_t, typename Select::_used_outer_tables>::size::value > 0; diff --git a/include/sqlpp11/simple_column.h b/include/sqlpp11/simple_column.h index 7bd0c02e..e9cff94f 100644 --- a/include/sqlpp11/simple_column.h +++ b/include/sqlpp11/simple_column.h @@ -35,7 +35,8 @@ namespace sqlpp template struct simple_column_t { - Column _column; + using _column_t = Column; + _column_t _column; using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; @@ -49,7 +50,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - context << t._column._get_name(); + context << name_of::char_ptr(); return context; } }; diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index 1b8839a9..fe4efefa 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -65,7 +65,7 @@ namespace sqlpp using _data_t = single_table_data_t; - struct _name_t {}; + struct _alias_t {}; // Member implementation with data and methods template diff --git a/include/sqlpp11/some.h b/include/sqlpp11/some.h index d457680d..04f351fe 100644 --- a/include/sqlpp11/some.h +++ b/include/sqlpp11/some.h @@ -29,6 +29,7 @@ #include #include +#include namespace sqlpp { @@ -38,9 +39,10 @@ namespace sqlpp using _traits = make_traits, tag::is_multi_expression>; using _recursive_traits = make_recursive_traits
::size::value == 0, "table aliases must not depend on external tables"); - using _name_t = typename AliasProvider::_name_t; + using _alias_t = typename AliasProvider::_alias_t; using _column_tuple_t = std::tuple...>; table_alias_t(Table table): @@ -74,7 +74,7 @@ namespace sqlpp { context << "("; serialize(t._table, context); - context << ") AS " << T::_name_t::_get_name(); + context << ") AS " << name_of::char_ptr(); return context; } }; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index ec1510bb..e1980ec0 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -201,7 +201,10 @@ namespace sqlpp using recursive_tags_of = typename T::_recursive_traits::_tags; template - using name_of = typename T::_name_t; + using alias_of = typename T::_alias_t; + + template + using name_of = typename T::_alias_t::_name_t; template struct make_traits @@ -239,7 +242,7 @@ namespace sqlpp }; template - using member_t = typename NameProvider::_name_t::template _member_t; + using member_t = typename NameProvider::_alias_t::template _member_t; template using derived_statement_t = typename Policies::_statement_t; diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index 7e1058f6..b24a81fc 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -44,7 +44,7 @@ namespace sqlpp struct update_t: public statement_name_t { using _traits = make_traits; - struct _name_t {}; + struct _alias_t {}; template struct _result_methods_t diff --git a/include/sqlpp11/verbatim_table.h b/include/sqlpp11/verbatim_table.h index a58a7e56..275061b6 100644 --- a/include/sqlpp11/verbatim_table.h +++ b/include/sqlpp11/verbatim_table.h @@ -35,8 +35,10 @@ namespace sqlpp { struct unusable_pseudo_column_t { - struct _name_t + struct _alias_t { + static constexpr const char _literal[] = "pseudo_column"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -53,7 +55,11 @@ namespace sqlpp using _provided_outer_tables = detail::type_set; }; - struct _name_t {}; + struct _alias_t + { + static constexpr const char _literal[] = "verbatim_table"; // FIXME need to use alias for verbatim table + using _name_t = sqlpp::make_char_sequence; + }; verbatim_table_t(std::string representation): _representation(representation) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index dd09cf86..67d885ee 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -118,6 +118,7 @@ print('#define '+get_include_guard_name(namespace, pathToHeader), file=header) print('', file=header) print('#include <' + INCLUDE + '/table.h>', file=header) print('#include <' + INCLUDE + '/column_types.h>', file=header) +print('#include <' + INCLUDE + '/char_sequence.h>', file=header) print('', file=header) print('namespace ' + namespace, file=header) print('{', file=header) @@ -143,9 +144,10 @@ for tableCreation in tableCreations: columnCanBeNull = not column.notNull print(' struct ' + columnClass, file=header) print(' {', file=header) - print(' struct _name_t', file=header) + print(' struct _alias_t', file=header) print(' {', file=header) - print(' static constexpr const char* _get_name() { return "' + sqlColumnName + '"; }', file=header) + print(' static constexpr const char _literal[] = "' + sqlColumnName + '";', file=header) + print(' using _name_t = sqlpp::make_char_sequence;', file=header) print(' template', file=header) print(' struct _member_t', file=header) print(' {', file=header) @@ -154,7 +156,6 @@ for tableCreation in tableCreations: print(' const T& operator()() const { return ' + columnMember + '; }', file=header) print(' };', file=header) print(' };', file=header) - #print(sqlColumnType) traitslist = [NAMESPACE + '::' + types[sqlColumnType]]; requireInsert = True if column.hasAutoValue: @@ -175,9 +176,10 @@ for tableCreation in tableCreations: print(' struct ' + tableClass + ': ' + NAMESPACE + '::table_t<' + tableTemplateParameters + '>', file=header) print(' {', file=header) - print(' struct _name_t', file=header) + print(' struct _alias_t', file=header) print(' {', file=header) - print(' static constexpr const char* _get_name() { return "' + sqlTableName + '"; }', file=header) + print(' static constexpr const char _literal[] = "' + sqlTableName + '";', file=header) + print(' using _name_t = sqlpp::make_char_sequence;', file=header) print(' template', file=header) print(' struct _member_t', file=header) print(' {', file=header) diff --git a/tests/Sample.h b/tests/Sample.h index 5f1bf1de..2fa909e5 100644 --- a/tests/Sample.h +++ b/tests/Sample.h @@ -3,6 +3,7 @@ #include #include +#include namespace test { @@ -10,9 +11,10 @@ namespace test { struct Delta { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "delta"; } + static constexpr const char _literal[] = "delta"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -25,9 +27,10 @@ namespace test }; struct Epsilon { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "epsilon"; } + static constexpr const char _literal[] = "epsilon"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -40,9 +43,10 @@ namespace test }; struct Omega { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "omega"; } + static constexpr const char _literal[] = "omega"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -60,9 +64,10 @@ namespace test TabFoo_::Epsilon, TabFoo_::Omega> { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "tab_foo"; } + static constexpr const char _literal[] = "tab_foo"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -76,9 +81,10 @@ namespace test { struct Alpha { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "alpha"; } + static constexpr const char _literal[] = "alpha"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -91,9 +97,10 @@ namespace test }; struct Beta { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "beta"; } + static constexpr const char _literal[] = "beta"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -106,9 +113,10 @@ namespace test }; struct Gamma { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "gamma"; } + static constexpr const char _literal[] = "gamma"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -121,9 +129,10 @@ namespace test }; struct Delta { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "delta"; } + static constexpr const char _literal[] = "delta"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { @@ -142,9 +151,10 @@ namespace test TabBar_::Gamma, TabBar_::Delta> { - struct _name_t + struct _alias_t { - static constexpr const char* _get_name() { return "tab_bar"; } + static constexpr const char _literal[] = "tab_bar"; + using _name_t = sqlpp::make_char_sequence; template struct _member_t { diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index 76138240..1ff66977 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -41,7 +41,6 @@ int main() test::TabFoo f; test::TabBar t; - select(t.alpha).flags(sqlpp::all).from(t); for (const auto& row : db(select(all_of(t)).from(t).where(true))) { int64_t a = row.alpha; From f97dc684288282fe23fc94105f13a76c4c101124 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 30 Nov 2014 20:19:38 +0100 Subject: [PATCH 045/105] Fixed missing std:: --- include/sqlpp11/char_sequence.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/char_sequence.h b/include/sqlpp11/char_sequence.h index 97a74e93..ba05d749 100644 --- a/include/sqlpp11/char_sequence.h +++ b/include/sqlpp11/char_sequence.h @@ -43,7 +43,7 @@ namespace sqlpp template struct make_char_sequence_impl; - template + template struct make_char_sequence_impl> { using type = char_sequence; From acba273230995695fc04c0cebdeaa67c9f703450 Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 3 Dec 2014 17:21:12 +0100 Subject: [PATCH 046/105] Fixed a problem with sub selects in binary operators There were missing braces for sub selects in expressions like tab.id == select(max(tab.id)).from(tab).where(true) --- include/sqlpp11/alias.h | 5 ++--- include/sqlpp11/assignment.h | 2 +- include/sqlpp11/avg.h | 6 +++++- include/sqlpp11/count.h | 6 +++++- include/sqlpp11/expression.h | 18 +++++++++--------- include/sqlpp11/functions.h | 7 ++++++- include/sqlpp11/in.h | 3 +-- include/sqlpp11/insert_value.h | 2 +- include/sqlpp11/interpret_tuple.h | 9 ++++----- include/sqlpp11/interpretable.h | 13 ++++++++++++- include/sqlpp11/is_not_null.h | 2 +- include/sqlpp11/is_null.h | 2 +- include/sqlpp11/like.h | 2 +- include/sqlpp11/limit.h | 2 +- include/sqlpp11/named_interpretable.h | 13 ++++++++++++- include/sqlpp11/not_in.h | 5 ++--- include/sqlpp11/offset.h | 2 +- include/sqlpp11/serialize.h | 17 +++++++++++++++++ include/sqlpp11/sort_order.h | 2 +- include/sqlpp11/sum.h | 5 ++++- 20 files changed, 87 insertions(+), 36 deletions(-) diff --git a/include/sqlpp11/alias.h b/include/sqlpp11/alias.h index 2f5b9c1f..0f792085 100644 --- a/include/sqlpp11/alias.h +++ b/include/sqlpp11/alias.h @@ -54,9 +54,8 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - context << '('; - serialize(t._expression, context); - context << ") AS "; + serialize_operand(t._expression, context); + context << " AS "; context << name_of::char_ptr(); return context; } diff --git a/include/sqlpp11/assignment.h b/include/sqlpp11/assignment.h index 95e357cd..09c46d64 100644 --- a/include/sqlpp11/assignment.h +++ b/include/sqlpp11/assignment.h @@ -73,7 +73,7 @@ namespace sqlpp { serialize(simple_column(t._lhs), context); context << "="; - serialize(t._rhs, context); + serialize_operand(t._rhs, context); return context; } }; diff --git a/include/sqlpp11/avg.h b/include/sqlpp11/avg.h index 629a2f12..8f313185 100644 --- a/include/sqlpp11/avg.h +++ b/include/sqlpp11/avg.h @@ -82,8 +82,12 @@ namespace sqlpp { serialize(Flag(), context); context << ' '; + serialize_operand(t._expr, context); + } + else + { + serialize(t._expr, context); } - serialize(t._expr, context); context << ")"; return context; } diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index 5ef81c6b..ffe74bc4 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -92,8 +92,12 @@ namespace sqlpp { serialize(Flag(), context); context << ' '; + serialize_operand(t._expr, context); + } + else + { + serialize(t._expr, context); } - serialize(t._expr, context); context << ")"; return context; } diff --git a/include/sqlpp11/expression.h b/include/sqlpp11/expression.h index 74e6f876..c2fc6990 100644 --- a/include/sqlpp11/expression.h +++ b/include/sqlpp11/expression.h @@ -72,7 +72,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { context << "("; - serialize(t._lhs, context); + serialize_operand(t._lhs, context); if (t._rhs._is_null()) { context << " IS NULL"; @@ -80,7 +80,7 @@ namespace sqlpp else { context << "="; - serialize(t._rhs, context); + serialize_operand(t._rhs, context); } context << ")"; return context; @@ -121,7 +121,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { context << "("; - serialize(t._lhs, context); + serialize_operand(t._lhs, context); if (t._rhs._is_null()) { context << " IS NOT NULL"; @@ -129,7 +129,7 @@ namespace sqlpp else { context << "!="; - serialize(t._rhs, context); + serialize_operand(t._rhs, context); } context << ")"; return context; @@ -168,13 +168,13 @@ namespace sqlpp context << "("; if (trivial_value_is_null_t::value) { - serialize(t._rhs, context); + serialize_operand(t._rhs, context); context << " IS NULL "; } else { context << "NOT "; - serialize(t._rhs, context); + serialize_operand(t._rhs, context); } context << ")"; @@ -214,9 +214,9 @@ namespace sqlpp static Context& _(const T& t, Context& context) { context << "("; - serialize(t._lhs, context); + serialize_operand(t._lhs, context); context << O::_name; - serialize(t._rhs, context); + serialize_operand(t._rhs, context); context << ")"; return context; } @@ -253,7 +253,7 @@ namespace sqlpp { context << "("; context << O::_name; - serialize(t._rhs, context); + serialize_operand(t._rhs, context); context << ")"; return context; } diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index b31dd741..409adbfb 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -107,6 +107,11 @@ namespace sqlpp static Context& _(const T& t, Context& context) { + if (t._container.size() == 1) + { + return serialize(value(t._container[0]), context); + } + bool first = true; for (const auto& entry: t._container) { @@ -115,7 +120,7 @@ namespace sqlpp else context << ','; - serialize(value(entry), context); + serialize_operand(value(entry), context); } return context; } diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index 613b1158..da39c909 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -82,8 +82,7 @@ namespace sqlpp serialize(t._operand, context); context << " IN("; if (sizeof...(Args) == 1) - serialize(std::get<0>(t._args), context); // FIXME: this is a bit of a hack until there is a better overall strategy for using braces - // see https://github.com/rbock/sqlpp11/issues/18 + serialize(std::get<0>(t._args), context); else interpret_tuple(t._args, ',', context); context << ')'; diff --git a/include/sqlpp11/insert_value.h b/include/sqlpp11/insert_value.h index 4845b217..ba7ce56a 100644 --- a/include/sqlpp11/insert_value.h +++ b/include/sqlpp11/insert_value.h @@ -116,7 +116,7 @@ namespace sqlpp else if (t._is_default) context << "DEFAULT"; else - serialize(t._value, context); + serialize_operand(t._value, context); return context; } }; diff --git a/include/sqlpp11/interpret_tuple.h b/include/sqlpp11/interpret_tuple.h index 518c607c..36c047b7 100644 --- a/include/sqlpp11/interpret_tuple.h +++ b/include/sqlpp11/interpret_tuple.h @@ -39,11 +39,10 @@ namespace sqlpp { if (index) context << separator; - if (UseBraces::value and requires_braces_t::value) - context << "("; - serialize(element, context); - if (UseBraces::value and requires_braces_t::value) - context << ")"; + if (UseBraces::value) + serialize_operand(element, context); + else + serialize(element, context); } template diff --git a/include/sqlpp11/interpretable.h b/include/sqlpp11/interpretable.h index 2e22ca9d..c5104d83 100644 --- a/include/sqlpp11/interpretable.h +++ b/include/sqlpp11/interpretable.h @@ -43,6 +43,7 @@ namespace sqlpp template interpretable_t(T t): + _requires_braces(requires_braces_t::value), _impl(std::make_shared<_impl_t>(t)) {} @@ -71,6 +72,8 @@ namespace sqlpp return _impl->interpret(context); } + bool _requires_braces; + private: struct _impl_base { @@ -119,7 +122,15 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - t.serialize(context); + if (t._requires_braces) + { + context << '('; + t.serialize(context); + context << ')'; + } + else + t.serialize(context); + return context; } }; diff --git a/include/sqlpp11/is_not_null.h b/include/sqlpp11/is_not_null.h index 3db4f148..0248ce5f 100644 --- a/include/sqlpp11/is_not_null.h +++ b/include/sqlpp11/is_not_null.h @@ -74,7 +74,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - serialize(t._operand, context); + serialize_operand(t._operand, context); context << " IS NOT NULL"; return context; } diff --git a/include/sqlpp11/is_null.h b/include/sqlpp11/is_null.h index f40d7cf5..f45f35c6 100644 --- a/include/sqlpp11/is_null.h +++ b/include/sqlpp11/is_null.h @@ -74,7 +74,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - serialize(t._operand, context); + serialize_operand(t._operand, context); context << " IS NULL"; return context; } diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index 9ae9940c..97d41e4a 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -78,7 +78,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - serialize(t._operand, context); + serialize_operand(t._operand, context); context << " LIKE("; serialize(t._pattern, context); context << ")"; diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 050da15c..6d3760d7 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -257,7 +257,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { context << " LIMIT "; - serialize(t._value, context); + serialize_operand(t._value, context); return context; } }; diff --git a/include/sqlpp11/named_interpretable.h b/include/sqlpp11/named_interpretable.h index 6ebacd04..47879ec8 100644 --- a/include/sqlpp11/named_interpretable.h +++ b/include/sqlpp11/named_interpretable.h @@ -42,6 +42,7 @@ namespace sqlpp template named_interpretable_t(T t): + _requires_braces(requires_braces_t::value), _impl(std::make_shared<_impl_t>(t)) {} @@ -75,6 +76,8 @@ namespace sqlpp return _impl->_get_name(); } + bool _requires_braces; + private: struct _impl_base { @@ -129,7 +132,15 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - t.serialize(context); + if (t._requires_braces) + { + context << '('; + t.serialize(context); + context << ')'; + } + else + t.serialize(context); + return context; } }; diff --git a/include/sqlpp11/not_in.h b/include/sqlpp11/not_in.h index 0aa47547..a8eda8e2 100644 --- a/include/sqlpp11/not_in.h +++ b/include/sqlpp11/not_in.h @@ -79,11 +79,10 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - serialize(t._operand, context); + serialize_operand(t._operand, context); context << " NOT IN("; if (sizeof...(Args) == 1) - serialize(std::get<0>(t._args), context); // FIXME: this is a bit of a hack until there is a better overall strategy for using braces - // see https://github.com/rbock/sqlpp11/issues/18 + serialize(std::get<0>(t._args), context); else interpret_tuple(t._args, ',', context); context << ')'; diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index 0b3253a2..a43f57bc 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -255,7 +255,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { context << " OFFSET "; - serialize(t._value, context); + serialize_operand(t._value, context); return context; } }; diff --git a/include/sqlpp11/serialize.h b/include/sqlpp11/serialize.h index 69e79fe5..b9fb2cae 100644 --- a/include/sqlpp11/serialize.h +++ b/include/sqlpp11/serialize.h @@ -28,6 +28,7 @@ #define SQLPP_SERIALIZE_H #include +#include namespace sqlpp { @@ -37,6 +38,22 @@ namespace sqlpp { return serializer_t::_(t, context); } + + template + auto serialize_operand(const T& t, Context& context) + -> decltype(serializer_t::_(t, context)) + { + if (requires_braces_t::value) + { + context << '('; + serializer_t::_(t, context); + context << ')'; + } + else + serializer_t::_(t, context); + + return context; + } } #endif diff --git a/include/sqlpp11/sort_order.h b/include/sqlpp11/sort_order.h index 04cfaab7..a5e64e8d 100644 --- a/include/sqlpp11/sort_order.h +++ b/include/sqlpp11/sort_order.h @@ -55,7 +55,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - serialize(t._expression, context); + serialize_operand(t._expression, context); switch(SortType) { case sort_type::asc: diff --git a/include/sqlpp11/sum.h b/include/sqlpp11/sum.h index 7bd42a9a..6492d39f 100644 --- a/include/sqlpp11/sum.h +++ b/include/sqlpp11/sum.h @@ -82,8 +82,11 @@ namespace sqlpp { serialize(Flag(), context); context << ' '; + serialize_operand(t._expr, context); } - serialize(t._expr, context); + else + serialize(t._expr, context); + context << ")"; return context; } From a6932070c39dd56a961d8dd251da8cd7f37cdf74 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 10 Jan 2015 18:30:29 +0100 Subject: [PATCH 047/105] Added a first version of the union function. --- include/sqlpp11/select.h | 4 +- include/sqlpp11/type_traits.h | 1 + include/sqlpp11/union.h | 225 ++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 25 ++-- tests/UnionTest.cpp | 52 ++++++++ 5 files changed, 294 insertions(+), 13 deletions(-) create mode 100644 include/sqlpp11/union.h create mode 100644 tests/UnionTest.cpp diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 1da653e0..b663c7d4 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -78,7 +79,8 @@ namespace sqlpp no_having_t, no_order_by_t, no_limit_t, - no_offset_t>; + no_offset_t, + no_union_t>; inline blank_select_t select() // FIXME: These should be constexpr diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index e1980ec0..04ffc42a 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -149,6 +149,7 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(is_order_by); SQLPP_VALUE_TRAIT_GENERATOR(is_limit); SQLPP_VALUE_TRAIT_GENERATOR(is_offset); + SQLPP_VALUE_TRAIT_GENERATOR(is_union); SQLPP_VALUE_TRAIT_GENERATOR(is_using_); SQLPP_VALUE_TRAIT_GENERATOR(is_column_list); SQLPP_VALUE_TRAIT_GENERATOR(is_multi_column); diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h new file mode 100644 index 00000000..e6d6cb01 --- /dev/null +++ b/include/sqlpp11/union.h @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNION_H +#define SQLPP_UNION_H + +#include +#include +#include +#include +#include +#include +#include + +namespace sqlpp +{ + struct no_union_t; + + using blank_union_t = statement_t; + // There is no limit or offset in union, use it as a pseudo table to do that. + + template + struct union_statement_impl + { + using type = statement_t; + }; + + template + struct union_statement_impl + { + using type = bad_statement; + }; + + template + using union_statement_t = typename union_statement_impl::type; + + + // UNION DATA + template + struct union_data_t + { + union_data_t(Lhs lhs, Rhs rhs): + _lhs(lhs), + _rhs(rhs) + {} + + union_data_t(const union_data_t&) = default; + union_data_t(union_data_t&&) = default; + union_data_t& operator=(const union_data_t&) = default; + union_data_t& operator=(union_data_t&&) = default; + ~union_data_t() = default; + + Lhs _lhs; + Rhs _rhs; + }; + + // UNION(EXPR) + template + struct union_t + { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits; + + // Data + using _data_t = union_data_t; + + // Member implementation with data and methods + template + struct _impl_t + { + public: + _data_t _data; + }; + + // Base template to be inherited by the statement + template + struct _base_t + { + using _data_t = union_data_t; + + _impl_t union_; + _impl_t& operator()() { return union_; } + const _impl_t& operator()() const { return union_; } + + template + static auto _get_member(T t) -> decltype(t.union_) + { + return t.union_; + } + + using _consistency_check = consistent_t; + }; + + using _result_methods_t = typename Lhs::template _result_methods_t; + }; + + // NO UNION YET + struct no_union_t + { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + + // Data + using _data_t = no_data_t; + + // Member implementation with data and methods + template + struct _impl_t + { + _data_t _data; + }; + + // Base template to be inherited by the statement + template + struct _base_t + { + using _data_t = no_data_t; + + _impl_t no_union; + _impl_t& operator()() { return no_union; } + const _impl_t& operator()() const { return no_union; } + + template + static auto _get_member(T t) -> decltype(t.no_union) + { + return t.no_union; + } + + using _database_t = typename Policies::_database_t; + + template + using _check = logic::all_t::value...>; // FIXME and consistent/runnable + + template + using _new_statement_t = union_statement_t; + + using _consistency_check = consistent_t; + + template + auto union_(Rhs rhs) const + -> _new_statement_t<_check, union_t, Rhs>> + { + // Being a select might be determined by the return type? + //FIXME static_assert(is_select this and Rhs, "at least one argument is not an expression in union_()"); + //FIXME static_assert(same return type, "at least one argument is not an expression in union_()"); + //FIXME static_assert(consistent/runnable this and Rhs, "at least one expression argument required in union_()"); + //FIXME static_assert(no order_y in this and Rhs, "at least one expression argument required in union_()"); + + return _union_impl(_check, Rhs>{}, rhs); + } + + template + auto union_(all_t, Rhs rhs) const + -> _new_statement_t<_check, union_t, Rhs>> + { + //FIXME static_assert(is_select this and Rhs, "at least one argument is not an expression in union_()"); + //FIXME static_assert(same return type, "at least one argument is not an expression in union_()"); + //FIXME static_assert(consistent/runnable this and Rhs, "at least one expression argument required in union_()"); + //FIXME static_assert(no order_y in this and Rhs, "at least one expression argument required in union_()"); + + return _union_impl(_check, Rhs>{}, rhs); + } + + private: + template + auto _union_impl(const std::false_type&, Rhs rhs) const + -> bad_statement; + + template + auto _union_impl(const std::true_type&, Rhs rhs) const + -> _new_statement_t, Rhs>> + { + return { blank_union_t{}, + union_data_t<_database_t, Flag, derived_statement_t, Rhs>{static_cast&>(*this), rhs} }; + } + + }; + }; + + // Interpreters + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = union_data_t; + + static Context& _(const T& t, Context& context) + { + serialize(t._lhs, context); + context << " UNION "; + serialize(Flag{}, context); + context << " "; + serialize(t._rhs, context); + return context; + } + }; + +} + +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d7198069..f3127acf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,18 +6,19 @@ macro (build_and_run arg) add_test("${arg}" "${arg}") endmacro () -build_and_run(BooleanExpressionTest) -build_and_run(CustomQueryTest) -build_and_run(InterpretTest) -build_and_run(InsertTest) -build_and_run(RemoveTest) -build_and_run(UpdateTest) -build_and_run(SelectTest) -build_and_run(SelectTypeTest) -build_and_run(FunctionTest) -build_and_run(PreparedTest) -build_and_run(Minimalistic) -build_and_run(ResultTest) +#build_and_run(BooleanExpressionTest) +#build_and_run(CustomQueryTest) +#build_and_run(InterpretTest) +#build_and_run(InsertTest) +#build_and_run(RemoveTest) +#build_and_run(UpdateTest) +#build_and_run(SelectTest) +#build_and_run(SelectTypeTest) +#build_and_run(FunctionTest) +#build_and_run(PreparedTest) +#build_and_run(Minimalistic) +#build_and_run(ResultTest) +build_and_run(UnionTest) # if you want to use the generator, you can do something like this: #find_package(PythonInterp REQUIRED) diff --git a/tests/UnionTest.cpp b/tests/UnionTest.cpp new file mode 100644 index 00000000..ee8b021c --- /dev/null +++ b/tests/UnionTest.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Sample.h" +#include "MockDb.h" +#include +#include + +MockDb db; +MockDb::_serializer_context_t printer; + +int main() +{ + test::TabBar t; + test::TabFoo f; + + auto u = select(t.alpha).from(t).union_(select(f.epsilon).from(f)); + + printer.reset(); + std::cerr << serialize(u, printer).str() << std::endl; + + auto ua = select(t.alpha).from(t).union_(sqlpp::all, select(f.epsilon).from(f)); + + printer.reset(); + std::cerr << serialize(ua, printer).str() << std::endl; + + db(u); + + return 0; +} From b4f62a5eb6bf48d92766017dee7855c6674cad11 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 11 Jan 2015 14:02:15 +0100 Subject: [PATCH 048/105] Union can be used as pseudo-table, allowing to union unions --- include/sqlpp11/select_column_list.h | 5 ++++- include/sqlpp11/union.h | 31 ++++++++++++++++++---------- tests/UnionTest.cpp | 10 +++++++-- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index eedf03e3..76a61c76 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -229,6 +229,9 @@ namespace sqlpp _impl_t& operator()() { return selected_columns; } const _impl_t& operator()() const { return selected_columns; } + _impl_t& get_selected_columns() { return selected_columns; } + const _impl_t& get_selected_columns() const { return selected_columns; } + template static auto _get_member(T t) -> decltype(t.selected_columns) { @@ -290,7 +293,7 @@ namespace sqlpp const _dynamic_names_t& get_dynamic_names() const { - return _get_statement().selected_columns._data._dynamic_columns._dynamic_expression_names; + return _get_statement().get_selected_columns()._data._dynamic_columns._dynamic_expression_names; } size_t get_no_of_result_columns() const diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index e6d6cb01..4e65f95e 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -40,14 +40,13 @@ namespace sqlpp struct no_union_t; using blank_union_t = statement_t; - // There is no limit or offset in union, use it as a pseudo table to do that. + // There is no order by or limit or offset in union, use it as a pseudo table to do that. template struct union_statement_impl { - using type = statement_t; + using type = statement_t; }; template @@ -83,9 +82,11 @@ namespace sqlpp template struct union_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits; + using _alias_t = struct{}; + // Data using _data_t = union_data_t; @@ -107,6 +108,10 @@ namespace sqlpp _impl_t& operator()() { return union_; } const _impl_t& operator()() const { return union_; } + using _selected_columns_t = decltype(union_._data._lhs.selected_columns); + _selected_columns_t& get_selected_columns() { return union_._data._lhs.selected_columns;} + const _selected_columns_t& get_selected_columns() const { return union_._data._lhs.selected_columns; } + template static auto _get_member(T t) -> decltype(t.union_) { @@ -116,7 +121,8 @@ namespace sqlpp using _consistency_check = consistent_t; }; - using _result_methods_t = typename Lhs::template _result_methods_t; + template + using _result_methods_t = typename Lhs::template _result_methods_t; }; // NO UNION YET @@ -162,20 +168,21 @@ namespace sqlpp using _consistency_check = consistent_t; template - auto union_(Rhs rhs) const - -> _new_statement_t<_check, union_t, Rhs>> + auto union_distinct(Rhs rhs) const + -> _new_statement_t<_check, union_t, Rhs>> { + static_assert(is_statement_t::value, "argument of union call has to be a statement"); // Being a select might be determined by the return type? //FIXME static_assert(is_select this and Rhs, "at least one argument is not an expression in union_()"); //FIXME static_assert(same return type, "at least one argument is not an expression in union_()"); //FIXME static_assert(consistent/runnable this and Rhs, "at least one expression argument required in union_()"); //FIXME static_assert(no order_y in this and Rhs, "at least one expression argument required in union_()"); - return _union_impl(_check, Rhs>{}, rhs); + return _union_impl(_check, Rhs>{}, rhs); } template - auto union_(all_t, Rhs rhs) const + auto union_all(Rhs rhs) const -> _new_statement_t<_check, union_t, Rhs>> { //FIXME static_assert(is_select this and Rhs, "at least one argument is not an expression in union_()"); @@ -211,11 +218,13 @@ namespace sqlpp static Context& _(const T& t, Context& context) { + context << '('; serialize(t._lhs, context); - context << " UNION "; + context << ") UNION "; serialize(Flag{}, context); - context << " "; + context << " ("; serialize(t._rhs, context); + context << ')'; return context; } }; diff --git a/tests/UnionTest.cpp b/tests/UnionTest.cpp index ee8b021c..a5646c55 100644 --- a/tests/UnionTest.cpp +++ b/tests/UnionTest.cpp @@ -26,6 +26,7 @@ #include "Sample.h" #include "MockDb.h" #include +#include #include MockDb db; @@ -36,16 +37,21 @@ int main() test::TabBar t; test::TabFoo f; - auto u = select(t.alpha).from(t).union_(select(f.epsilon).from(f)); + auto u = select(t.alpha).from(t).union_distinct(select(f.epsilon).from(f)); printer.reset(); std::cerr << serialize(u, printer).str() << std::endl; - auto ua = select(t.alpha).from(t).union_(sqlpp::all, select(f.epsilon).from(f)); + auto ua = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u); printer.reset(); std::cerr << serialize(ua, printer).str() << std::endl; + auto uu = select(all_of(ua)).from(ua).union_all(select(t.delta).from(t)); + + printer.reset(); + std::cerr << serialize(uu, printer).str() << std::endl; + db(u); return 0; From c4ee228f12fd1f9d102adc420990c1370227024d Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 11 Jan 2015 16:12:39 +0100 Subject: [PATCH 049/105] Make MockDb a bit more talkative for tests --- tests/MockDb.h | 9 +++++++++ tests/UnionTest.cpp | 18 ++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tests/MockDb.h b/tests/MockDb.h index 7d200eb1..567866d2 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -27,6 +27,7 @@ #define SQLPP_MOCK_DB_H #include +#include #include #include @@ -133,6 +134,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running execute call with\n" << context.str() << std::endl; } template @@ -140,6 +142,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running insert call with\n" << context.str() << std::endl; return 0; } @@ -148,6 +151,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running update call with\n" << context.str() << std::endl; return 0; } @@ -156,6 +160,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running remove call with\n" << context.str() << std::endl; return 0; } @@ -164,6 +169,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running select call with\n" << context.str() << std::endl; return {}; } @@ -195,6 +201,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running prepare execute call with\n" << context.str() << std::endl; return nullptr; } @@ -203,6 +210,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running prepare insert call with\n" << context.str() << std::endl; return nullptr; } @@ -222,6 +230,7 @@ struct MockDbT: public sqlpp::connection { _serializer_context_t context; ::sqlpp::serialize(x, context); + std::cout << "Running prepare select call with\n" << context.str() << std::endl; return nullptr; } diff --git a/tests/UnionTest.cpp b/tests/UnionTest.cpp index a5646c55..61436b7d 100644 --- a/tests/UnionTest.cpp +++ b/tests/UnionTest.cpp @@ -37,22 +37,12 @@ int main() test::TabBar t; test::TabFoo f; - auto u = select(t.alpha).from(t).union_distinct(select(f.epsilon).from(f)); + db(select(t.alpha).from(t).union_distinct(select(f.epsilon).from(f))); + db(select(t.alpha).from(t).union_all(select(f.epsilon).from(f))); - printer.reset(); - std::cerr << serialize(u, printer).str() << std::endl; + auto u = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u); - auto ua = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u); - - printer.reset(); - std::cerr << serialize(ua, printer).str() << std::endl; - - auto uu = select(all_of(ua)).from(ua).union_all(select(t.delta).from(t)); - - printer.reset(); - std::cerr << serialize(uu, printer).str() << std::endl; - - db(u); + db(select(all_of(u)).from(u).union_all(select(t.delta).from(t))); return 0; } From 8488dae0a7d4340eeb6bd730305ff50f7dc0093f Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 11 Jan 2015 17:10:36 +0100 Subject: [PATCH 050/105] Added a few compile-time checks for unions --- include/sqlpp11/union.h | 54 ++++++++++++++++++++++++++++++++++------- tests/UnionTest.cpp | 8 +++--- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 4e65f95e..615321dc 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -37,6 +37,43 @@ namespace sqlpp { + template + struct has_result_row_impl + { + using type = std::false_type; + }; + + template + struct has_result_row_impl::template _result_row_t>::value, + void>::type> + { + using type = std::true_type; + }; + + template + using has_result_row_t = typename has_result_row_impl::type; + + template + struct get_result_row_impl + { + using type = void; + }; + + template + struct get_result_row_impl::template _result_row_t>::value, + void>::type> + { + using type = typename Statement::template _result_methods_t::template _result_row_t; + }; + + template + using get_result_row_t = typename get_result_row_impl::type; + + struct no_union_t; using blank_union_t = statement_t _new_statement_t<_check, union_t, Rhs>> { static_assert(is_statement_t::value, "argument of union call has to be a statement"); - // Being a select might be determined by the return type? - //FIXME static_assert(is_select this and Rhs, "at least one argument is not an expression in union_()"); - //FIXME static_assert(same return type, "at least one argument is not an expression in union_()"); - //FIXME static_assert(consistent/runnable this and Rhs, "at least one expression argument required in union_()"); - //FIXME static_assert(no order_y in this and Rhs, "at least one expression argument required in union_()"); + static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); + static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); + static_assert(std::is_same>, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); return _union_impl(_check, Rhs>{}, rhs); } @@ -185,10 +220,11 @@ namespace sqlpp auto union_all(Rhs rhs) const -> _new_statement_t<_check, union_t, Rhs>> { - //FIXME static_assert(is_select this and Rhs, "at least one argument is not an expression in union_()"); - //FIXME static_assert(same return type, "at least one argument is not an expression in union_()"); - //FIXME static_assert(consistent/runnable this and Rhs, "at least one expression argument required in union_()"); - //FIXME static_assert(no order_y in this and Rhs, "at least one expression argument required in union_()"); + static_assert(is_statement_t::value, "argument of union call has to be a statement"); + static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); + static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); + static_assert(std::is_same>, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); + return _union_impl(_check, Rhs>{}, rhs); } diff --git a/tests/UnionTest.cpp b/tests/UnionTest.cpp index 61436b7d..b4462ded 100644 --- a/tests/UnionTest.cpp +++ b/tests/UnionTest.cpp @@ -37,12 +37,12 @@ int main() test::TabBar t; test::TabFoo f; - db(select(t.alpha).from(t).union_distinct(select(f.epsilon).from(f))); - db(select(t.alpha).from(t).union_all(select(f.epsilon).from(f))); + db(select(t.alpha).from(t).union_distinct(select(f.epsilon.as(t.alpha)).from(f))); + db(select(t.alpha).from(t).union_all(select(f.epsilon.as(t.alpha)).from(f))); - auto u = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u); + auto u = select(t.alpha).from(t).union_all(select(f.epsilon.as(t.alpha)).from(f)).as(sqlpp::alias::u); - db(select(all_of(u)).from(u).union_all(select(t.delta).from(t))); + db(select(all_of(u)).from(u).union_all(select(t.delta.as(t.alpha)).from(t))); return 0; } From 92e670118a63327f0b9190044158d66a02ea93cf Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 13 Jan 2015 21:53:29 +0100 Subject: [PATCH 051/105] Started to add common table expressions and 'with' --- include/sqlpp11/column.h | 6 +- include/sqlpp11/count.h | 2 + include/sqlpp11/cte.h | 61 ++++++++++ include/sqlpp11/extra_tables.h | 4 +- include/sqlpp11/join.h | 2 + include/sqlpp11/parameter.h | 6 +- include/sqlpp11/result_field_methods.h | 6 +- include/sqlpp11/select.h | 2 + include/sqlpp11/statement.h | 33 +++++- include/sqlpp11/table.h | 4 +- include/sqlpp11/table_alias.h | 4 +- include/sqlpp11/type_traits.h | 10 ++ include/sqlpp11/union.h | 3 +- include/sqlpp11/with.h | 158 +++++++++++++++++++++++++ tests/CMakeLists.txt | 1 + tests/WithTest.cpp | 40 +++++++ 16 files changed, 329 insertions(+), 13 deletions(-) create mode 100644 include/sqlpp11/cte.h create mode 100644 include/sqlpp11/with.h create mode 100644 tests/WithTest.cpp diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 82d34183..83468e5b 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -54,11 +54,13 @@ namespace sqlpp struct _recursive_traits { - using _parameters = std::tuple<>; + using _required_ctes = detail::type_set<>; + using _provided_ctes = detail::type_set<>; + using _required_tables = detail::type_set
; using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; - using _required_tables = detail::type_set
; using _extra_tables = detail::type_set<>; + using _parameters = std::tuple<>; using _tags = typename std::conditional::value, detail::type_set, detail::type_set<>>::type; diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index ffe74bc4..1403aa8b 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -41,6 +41,8 @@ namespace sqlpp using _traits = make_traits; struct _recursive_traits { + using _required_ctes = required_ctes_of; + using _provided_ctes = detail::type_set<>; using _required_tables = required_tables_of; using _provided_tables = provided_tables_of; using _provided_outer_tables = provided_outer_tables_of; diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h new file mode 100644 index 00000000..af31e09a --- /dev/null +++ b/include/sqlpp11/cte.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_CTE_H +#define SQLPP_CTE_H + +#include +#include +#include +#include +#include +#include +#include + +namespace sqlpp +{ + template + struct pre_cte_t + { + template + auto as(Statement statement) + -> cte + { + // FIXME: Need to check stuff here. + return { statement }; + } + }; + + template + auto cte(const AliasProvider&) + -> pre_cte_t + { + return {}; + } + +} + +#endif diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index 884e1946..cd4e1068 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -54,11 +54,13 @@ namespace sqlpp using _traits = make_traits; struct _recursive_traits { - using _parameters = std::tuple<>; + using _required_ctes = detail::make_joined_set_t...>; + using _provided_ctes = detail::type_set<>; using _required_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; using _provided_tables = detail::type_set<>; using _extra_tables = detail::type_set; + using _parameters = std::tuple<>; using _tags = detail::type_set<>; }; diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index 99dbcdd0..e4dcb97f 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -68,6 +68,8 @@ namespace sqlpp using _traits = make_traits; struct _recursive_traits { + using _required_ctes = detail::make_joined_set_t, required_ctes_of>; + using _provided_ctes = detail::type_set<>; using _required_tables = detail::make_joined_set_t, required_tables_of>; using _provided_tables = detail::make_joined_set_t, provided_tables_of>; using _provided_outer_tables = typename JoinType::template _provided_outer_tables; diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index b5daaabc..542a5cb1 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -40,11 +40,13 @@ namespace sqlpp using _traits = make_traits; struct _recursive_traits { - using _parameters = std::tuple; + using _required_ctes = detail::type_set<>; + using _provided_ctes = detail::type_set<>; + using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; - using _required_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; + using _parameters = std::tuple; using _tags = detail::type_set; }; diff --git a/include/sqlpp11/result_field_methods.h b/include/sqlpp11/result_field_methods.h index 5829ba91..4ab50af9 100644 --- a/include/sqlpp11/result_field_methods.h +++ b/include/sqlpp11/result_field_methods.h @@ -83,11 +83,13 @@ namespace sqlpp struct _recursive_traits { - using _parameters = std::tuple<>; + using _required_ctes = detail::type_set<>; + using _provided_ctes = detail::type_set<>; + using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; - using _required_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; + using _parameters = std::tuple<>; using _tags = typename std::conditional::value, detail::type_set, detail::type_set<>>::type; diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index b663c7d4..89506245 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -69,6 +70,7 @@ namespace sqlpp template using blank_select_t = statement_t struct statement_t; + struct assert_no_unknown_ctes_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "one clause requires common table expressions which are otherwise not known in the statement"); + } + }; + struct assert_no_unknown_tables_t { using type = std::false_type; @@ -84,6 +95,8 @@ namespace sqlpp template using _new_statement_t = typename _policies_update_t::type; + using _all_required_ctes = detail::make_joined_set_t...>; + using _all_provided_ctes = detail::make_joined_set_t...>; using _all_required_tables = detail::make_joined_set_t...>; using _all_provided_tables = detail::make_joined_set_t...>; using _all_provided_outer_tables = detail::make_joined_set_t...>; @@ -100,6 +113,12 @@ namespace sqlpp _all_provided_tables // Hint: extra_tables are not used here because they are just a helper for dynamic .add_*() >; + // The common table expressions not covered by the with. + using _required_ctes = detail::make_difference_set_t< + _all_required_ctes, + _all_provided_ctes + >; + using _result_type_provider = detail::get_last_if; struct _result_methods_t: public _result_type_provider::template _result_methods_t<_statement_t> @@ -111,7 +130,9 @@ namespace sqlpp // - the select is complete (leaks no tables) static constexpr bool _can_be_used_as_table() { - return is_select_column_list_t<_result_type_provider>::value and _required_tables::size::value == 0 + return is_select_column_list_t<_result_type_provider>::value + and _required_tables::size::value == 0 + and _required_ctes::size::value == 0 ? true : false; } @@ -133,6 +154,8 @@ namespace sqlpp struct _recursive_traits { + using _required_ctes = statement_policies_t::_required_ctes; + using _provided_ctes = detail::type_set<>; using _required_tables = statement_policies_t::_required_tables; using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; @@ -143,6 +166,8 @@ namespace sqlpp detail::type_set<>>::type; }; + using _cte_check = typename std::conditional<_required_ctes::size::value == 0, + consistent_t, assert_no_unknown_ctes_t>::type; using _table_check = typename std::conditional<_required_tables::size::value == 0, consistent_t, assert_no_unknown_tables_t>::type; using _parameter_check = typename std::conditional::value == 0, @@ -161,10 +186,12 @@ namespace sqlpp using _run_check = detail::get_first_if::_consistency_check..., - typename _policies_t::_table_check>; + typename _policies_t::_table_check, + typename _policies_t::_cte_check>; using _prepare_check = detail::get_first_if::_consistency_check..., - typename _policies_t::_table_check>; + typename _policies_t::_table_check, + typename _policies_t::_cte_check>; using _result_type_provider = typename _policies_t::_result_type_provider; template diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index b7bd5065..e5e6549c 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -48,11 +48,13 @@ namespace sqlpp struct _recursive_traits { - using _parameters = std::tuple<>; + using _required_ctes = detail::type_set<>; + using _provided_ctes = detail::type_set<>; using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set
; using _provided_outer_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; + using _parameters = std::tuple<>; using _tags = detail::type_set<>; }; diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index e7befef0..4985a875 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -44,11 +44,13 @@ namespace sqlpp struct _recursive_traits { - using _parameters = std::tuple<>; + using _required_ctes = required_ctes_of
; + using _provided_ctes = detail::type_set<>; using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set; using _provided_outer_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; + using _parameters = std::tuple<>; using _tags = detail::type_set<>; }; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 04ffc42a..4cf352ec 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -183,6 +183,12 @@ namespace sqlpp template using cpp_value_type_of = typename value_type_of::_cpp_value_type; + template + using required_ctes_of = typename T::_recursive_traits::_required_ctes; + + template + using provided_ctes_of = typename T::_recursive_traits::_provided_ctes; + template using required_tables_of = typename T::_recursive_traits::_required_tables; @@ -217,6 +223,8 @@ namespace sqlpp template struct make_recursive_traits { + using _required_ctes = detail::make_joined_set_t...>; + using _provided_ctes = detail::make_joined_set_t...>; using _required_tables = detail::make_joined_set_t...>; using _provided_tables = detail::make_joined_set_t...>; using _provided_outer_tables = detail::make_joined_set_t...>; @@ -228,6 +236,8 @@ namespace sqlpp template struct recursive_tags { + using _required_ctes = detail::type_set<>; + using _provided_ctes = detail::type_set<>; using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 615321dc..56559421 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -83,7 +83,7 @@ namespace sqlpp template struct union_statement_impl { - using type = statement_t; + using type = statement_t; }; template @@ -208,6 +208,7 @@ namespace sqlpp auto union_distinct(Rhs rhs) const -> _new_statement_t<_check, union_t, Rhs>> { +#warning: make sure that Rhs is a select, not a uninon static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h new file mode 100644 index 00000000..4811c8d7 --- /dev/null +++ b/include/sqlpp11/with.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_WITH_H +#define SQLPP_WITH_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sqlpp +{ + template + struct with_data_t + { + with_data_t(Expressions... expressions): + _expressions(expressions...) + {} + + with_data_t(const with_data_t&) = default; + with_data_t(with_data_t&&) = default; + with_data_t& operator=(const with_data_t&) = default; + with_data_t& operator=(with_data_t&&) = default; + ~with_data_t() = default; + + std::tuple _expressions; + interpretable_list_t _dynamic_expressions; + }; + + template + struct with_t + { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits; + + using _is_dynamic = is_database; + + // Data + using _data_t = with_data_t; + + // Member implementation with data and methods + template + struct _impl_t + { + public: + _data_t _data; + }; + + // Base template to be inherited by the statement + template + struct _base_t + { + using _data_t = with_data_t; + + _impl_t where; + _impl_t& operator()() { return where; } + const _impl_t& operator()() const { return where; } + + template + static auto _get_member(T t) -> decltype(t.where) + { + return t.where; + } + +#warning: Need real checks here + using _consistency_check = consistent_t; + }; + }; + + + struct no_with_t + { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + + // Data + using _data_t = no_data_t; + + // Member implementation with data and methods + template + struct _impl_t + { + _data_t _data; + }; + + // Base template to be inherited by the statement + template + struct _base_t + { + using _data_t = no_data_t; + + _impl_t no_with; + _impl_t& operator()() { return no_with; } + const _impl_t& operator()() const { return no_with; } + + template + static auto _get_member(T t) -> decltype(t.no_with) + { + return t.no_with; + } + + using _consistency_check = consistent_t; + + }; + }; + + template + struct blank_with_t + { + with_data_t _data; + + template + auto operator()(Statement statement) + -> new_statement_t> + { + // FIXME need checks here, e.g. if there is recursion + return { statement, _data }; + } + }; + + template + auto with(Expressions... cte) + -> blank_with_t + { + return { {cte...} }; + } +} + +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f3127acf..74505083 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,6 +19,7 @@ endmacro () #build_and_run(Minimalistic) #build_and_run(ResultTest) build_and_run(UnionTest) +build_and_run(WithTest) # if you want to use the generator, you can do something like this: #find_package(PythonInterp REQUIRED) diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp new file mode 100644 index 00000000..6932966e --- /dev/null +++ b/tests/WithTest.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Sample.h" +#include "MockDb.h" +#include +#include +#include + +MockDb db; +MockDb::_serializer_context_t printer; + +int main() +{ + // to be done + + return 0; +} From 61b0bd9ff8fe9f64f8c2ec2443397cc6e84b3013 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 15 Jan 2015 19:43:56 +0100 Subject: [PATCH 052/105] Can chain unions And a few more checks --- include/sqlpp11/select_column_list.h | 1 + include/sqlpp11/statement.h | 18 +++++----- include/sqlpp11/type_traits.h | 51 ++++++++++++++++++++++++++++ include/sqlpp11/union.h | 50 +++++---------------------- tests/UnionTest.cpp | 13 ++++--- 5 files changed, 79 insertions(+), 54 deletions(-) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 76a61c76..727e7513 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -286,6 +286,7 @@ namespace sqlpp template _alias_t as(const AliasProvider& aliasProvider) const { + run_check_t<_statement_t>::_(); static_assert(_statement_t::_can_be_used_as_table(), "statement cannot be used as table, e.g. due to missing tables"); static_assert(logic::none_t::value...>::value, "cannot use multi-columns in sub selects"); return _table_t(_get_statement()).as(aliasProvider); diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 02aaca64..3b4f5b56 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -107,6 +107,9 @@ namespace sqlpp template using _no_unknown_tables = detail::is_subset_of, _known_tables>; + template class Predicate> + using any_t = logic::any_t::value...>; + // The tables not covered by the from. using _required_tables = detail::make_difference_set_t< _all_required_tables, @@ -130,7 +133,7 @@ namespace sqlpp // - the select is complete (leaks no tables) static constexpr bool _can_be_used_as_table() { - return is_select_column_list_t<_result_type_provider>::value + return has_result_row_t<_statement_t>::value and _required_tables::size::value == 0 and _required_ctes::size::value == 0 ? true @@ -183,15 +186,14 @@ namespace sqlpp { using _policies_t = typename detail::statement_policies_t; + using _consistency_check = detail::get_first_if::_consistency_check..., + typename _policies_t::_table_check, + typename _policies_t::_cte_check>; using _run_check = detail::get_first_if::_consistency_check..., - typename _policies_t::_table_check, - typename _policies_t::_cte_check>; - using _prepare_check = detail::get_first_if::_consistency_check..., - typename _policies_t::_table_check, - typename _policies_t::_cte_check>; + _consistency_check>; + using _prepare_check = _consistency_check; using _result_type_provider = typename _policies_t::_result_type_provider; template diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 4cf352ec..31f6a68e 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -339,6 +339,57 @@ namespace sqlpp template using serialize_check_t = typename serialize_check::type; + template + struct has_result_row_impl + { + using type = std::false_type; + }; + + template + struct has_result_row_impl::template _result_row_t>::value, + void>::type> + { + using type = std::true_type; + }; + + template + using has_result_row_t = typename has_result_row_impl::type; + + template + struct get_result_row_impl + { + using type = void; + }; + + template + struct get_result_row_impl::template _result_row_t>::value, + void>::type> + { + using type = typename Statement::template _result_methods_t::template _result_row_t; + }; + + template + using get_result_row_t = typename get_result_row_impl::type; + + template class Predicate, typename Enable=void> + struct has_policy_impl + { + using type = std::false_type; + }; + + template class Predicate> + struct has_policy_impl::value>::type> + { + using type = std::true_type; + }; + + template class Predicate> + using has_policy_t = typename has_policy_impl::type; + } #endif diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 56559421..d68ab63b 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -37,42 +37,6 @@ namespace sqlpp { - template - struct has_result_row_impl - { - using type = std::false_type; - }; - - template - struct has_result_row_impl::template _result_row_t>::value, - void>::type> - { - using type = std::true_type; - }; - - template - using has_result_row_t = typename has_result_row_impl::type; - - template - struct get_result_row_impl - { - using type = void; - }; - - template - struct get_result_row_impl::template _result_row_t>::value, - void>::type> - { - using type = typename Statement::template _result_methods_t::template _result_row_t; - }; - - template - using get_result_row_t = typename get_result_row_impl::type; - struct no_union_t; @@ -119,7 +83,7 @@ namespace sqlpp template struct union_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits; using _alias_t = struct{}; @@ -145,9 +109,9 @@ namespace sqlpp _impl_t& operator()() { return union_; } const _impl_t& operator()() const { return union_; } - using _selected_columns_t = decltype(union_._data._lhs.selected_columns); - _selected_columns_t& get_selected_columns() { return union_._data._lhs.selected_columns;} - const _selected_columns_t& get_selected_columns() const { return union_._data._lhs.selected_columns; } + using _selected_columns_t = typename std::decay::type; + _selected_columns_t& get_selected_columns() { return union_._data._lhs.get_selected_columns(); } + const _selected_columns_t& get_selected_columns() const { return union_._data._lhs.get_selected_columns(); } template static auto _get_member(T t) -> decltype(t.union_) @@ -155,7 +119,9 @@ namespace sqlpp return t.union_; } - using _consistency_check = consistent_t; + using _consistency_check = detail::get_first_if; }; template @@ -208,8 +174,8 @@ namespace sqlpp auto union_distinct(Rhs rhs) const -> _new_statement_t<_check, union_t, Rhs>> { -#warning: make sure that Rhs is a select, not a uninon static_assert(is_statement_t::value, "argument of union call has to be a statement"); + static_assert(has_policy_t::value, "argument of union call has to be a select"); static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); static_assert(std::is_same>, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); diff --git a/tests/UnionTest.cpp b/tests/UnionTest.cpp index b4462ded..ca88841c 100644 --- a/tests/UnionTest.cpp +++ b/tests/UnionTest.cpp @@ -37,12 +37,17 @@ int main() test::TabBar t; test::TabFoo f; - db(select(t.alpha).from(t).union_distinct(select(f.epsilon.as(t.alpha)).from(f))); - db(select(t.alpha).from(t).union_all(select(f.epsilon.as(t.alpha)).from(f))); + db(select(t.alpha).from(t).where(true) + .union_distinct(select(f.epsilon.as(t.alpha)).from(f).where(true))); + db(select(t.alpha).from(t).where(true) + .union_all(select(f.epsilon.as(t.alpha)).from(f).where(true))); - auto u = select(t.alpha).from(t).union_all(select(f.epsilon.as(t.alpha)).from(f)).as(sqlpp::alias::u); + auto u = select(t.alpha).from(t).where(true).union_all(select(f.epsilon.as(t.alpha)).from(f).where(true)).as(sqlpp::alias::u); - db(select(all_of(u)).from(u).union_all(select(t.delta.as(t.alpha)).from(t))); + db(select(all_of(u)).from(u).where(true).union_all(select(t.delta.as(t.alpha)).from(t).where(true))); + db(select(u.alpha).from(u).where(true).union_all(select(t.delta.as(t.alpha)).from(t).where(true))); + + db(select(t.alpha).from(t).where(true).union_all(select(t.alpha).from(t).where(true)).union_all(select(t.alpha).from(t).where(true))); return 0; } From 1fb83ed9fa62dfae6d5c87145444eb008758ed36 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 19 Jan 2015 07:26:04 +0100 Subject: [PATCH 053/105] Consistency < Prepare < Run Consistency: No missing table Prepare: No missing cte Run: No parameter --- include/sqlpp11/statement.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 3b4f5b56..8fe803d7 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -188,12 +188,13 @@ namespace sqlpp using _consistency_check = detail::get_first_if::_consistency_check..., - typename _policies_t::_table_check, - typename _policies_t::_cte_check>; + typename _policies_t::_table_check>; + using _prepare_check = detail::get_first_if; using _run_check = detail::get_first_if; - using _prepare_check = _consistency_check; + _prepare_check>; using _result_type_provider = typename _policies_t::_result_type_provider; template From 08de44e8a8053ac96c62fee5361a2abe80d27dae Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 19 Jan 2015 09:16:41 +0100 Subject: [PATCH 054/105] Union works with static results only --- include/sqlpp11/result_row.h | 15 +++++++++++++++ include/sqlpp11/union.h | 10 +++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index f9e21fcf..628edc76 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -265,6 +265,21 @@ namespace sqlpp } } }; + + template + struct is_static_result_row_impl + { + using type = std::false_type; + }; + + template + struct is_static_result_row_impl> + { + using type = std::true_type; + }; + + template + using is_static_result_row_t = typename is_static_result_row_impl::type; } #endif diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index d68ab63b..575f2b08 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace sqlpp @@ -176,9 +177,12 @@ namespace sqlpp { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); - static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); - static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); - static_assert(std::is_same>, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); + static_assert(has_result_row_t::value, "argument of a union has to be a complete select statement"); + static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a complete select statement or union"); + static_assert(std::is_same>, get_result_row_t>::value, "both arguments in a union have to have the same result columns (type and name)"); + + using _result_row_t = get_result_row_t; + static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); return _union_impl(_check, Rhs>{}, rhs); } From 4112448b5bcaed5140cd6a8f0b5c5499b1589f5c Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 19 Jan 2015 09:17:21 +0100 Subject: [PATCH 055/105] Some ideas --- include/sqlpp11/cte.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index af31e09a..fb84e3c7 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -37,6 +37,10 @@ namespace sqlpp { +// The cte is displayed as AliasProviderName except within the with: +// - the with needs the +// AliasProviderName AS (ColumnNames) (select/union) +// The result row of the select should not have dynamic parts template struct pre_cte_t { From 12a0d9d6989018a5c8f78bbc9b99a479c5f7ef30 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 27 Jan 2015 08:29:10 +0100 Subject: [PATCH 056/105] cte.h compiles --- include/sqlpp11/cte.h | 57 ++++++++++++++++++++++++++- include/sqlpp11/result_row.h | 1 + include/sqlpp11/result_row_fwd.h | 39 ++++++++++++++++++ include/sqlpp11/select_pseudo_table.h | 2 + include/sqlpp11/with.h | 3 ++ 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 include/sqlpp11/result_row_fwd.h diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index fb84e3c7..7920a35b 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -27,6 +27,7 @@ #ifndef SQLPP_CTE_H #define SQLPP_CTE_H +#include #include #include #include @@ -37,6 +38,60 @@ namespace sqlpp { + template + struct cte_t; + + template + struct cte_column_spec_t + { + using _alias_t = typename FieldSpec::_alias_t; + + using _traits = make_traits, + tag::must_not_insert, + tag::must_not_update, + tag_if::value> + >; + }; + + template + struct make_cte_impl + { + using type = void; + }; + + template + struct make_cte_impl> + { + using type = cte_t...>; + }; + + template + using make_cte_t = typename make_cte_impl>::type; + + template + struct cte_t: public member_t>... // FIXME + { + using _alias_t = typename AliasProvider::_alias_t; + + Statement _statement; + }; + + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = cte_t; + + static Context& _(const T& t, Context& context) + { + context << name_of::char_ptr() << " AS ("; + serialize(t._statement, context); + context << ")"; + return context; + } + }; + + // The cte is displayed as AliasProviderName except within the with: // - the with needs the // AliasProviderName AS (ColumnNames) (select/union) @@ -46,7 +101,7 @@ namespace sqlpp { template auto as(Statement statement) - -> cte + -> make_cte_t { // FIXME: Need to check stuff here. return { statement }; diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 628edc76..67574354 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -28,6 +28,7 @@ #define SQLPP_RESULT_ROW_H #include +#include #include #include #include diff --git a/include/sqlpp11/result_row_fwd.h b/include/sqlpp11/result_row_fwd.h new file mode 100644 index 00000000..8df5b4ed --- /dev/null +++ b/include/sqlpp11/result_row_fwd.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_RESULT_ROW_FWD_H +#define SQLPP_RESULT_ROW_FWD_H + +namespace sqlpp +{ + template + struct result_row_t; + + template + struct dynamic_result_row_t; +} + +#endif diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 7e50d87a..c4dbd3b4 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -31,6 +31,8 @@ namespace sqlpp { + // FIXME: We might use field specs here (same as with cte) + // // provide type information for sub-selects that are used as named expressions or tables template struct select_column_spec_t diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 4811c8d7..8700641c 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -37,6 +37,9 @@ #include #include + +#include + namespace sqlpp { template From d9bd5f1b5c3d7c97b082af27a2b3477f7a69dc1a Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 27 Jan 2015 08:30:00 +0100 Subject: [PATCH 057/105] Adjusted .clang-format --- .clang-format | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..f94da0a4 --- /dev/null +++ b/.clang-format @@ -0,0 +1,53 @@ +Language: Cpp +AccessModifierOffset: -2 +ConstructorInitializerIndentWidth: 4 +AlignEscapedNewlinesLeft: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AlwaysBreakTemplateDeclarations: true +AlwaysBreakBeforeMultilineStrings: false +BreakBeforeBinaryOperators: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BinPackParameters: false +ColumnLimit: 160 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +DerivePointerAlignment: false +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: true +IndentWrappedFunctionNames: false +IndentFunctionDeclarationAfterType: false +MaxEmptyLinesToKeep: 1 +KeepEmptyLinesAtTheStartOfBlocks: false +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakString: 1000 +PenaltyBreakFirstLessLess: 120 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +SpacesBeforeTrailingComments: 2 +Cpp11BracedListStyle: true +Standard: Cpp11 +IndentWidth: 2 +TabWidth: 2 +UseTab: Never +BreakBeforeBraces: Allman +SpacesInParentheses: false +SpacesInAngles: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: true +SpaceBeforeAssignmentOperators: true +ContinuationIndentWidth: 4 +CommentPragmas: '^ IWYU pragma:' +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +SpaceBeforeParens: ControlStatements +DisableFormat: false From abfde5c9a7e7f013891d372c6c440442626a2fba Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 27 Jan 2015 18:27:33 +0100 Subject: [PATCH 058/105] Turned alias into an inline namespace which helps with ADL in cte --- include/sqlpp11/alias_provider.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/alias_provider.h b/include/sqlpp11/alias_provider.h index 266ec51e..ba07cf9f 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -62,7 +62,7 @@ namespace sqlpp static constexpr bool value = true; }; - namespace alias + inline namespace alias { SQLPP_ALIAS_PROVIDER(a); SQLPP_ALIAS_PROVIDER(b); From da9ca737883905b81236e2d2d22fd8cf362fa0c6 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 27 Jan 2015 18:28:36 +0100 Subject: [PATCH 059/105] First test constructing a cte --- include/sqlpp11/cte.h | 9 ++++++++- tests/WithTest.cpp | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 7920a35b..34b33506 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -73,6 +73,13 @@ namespace sqlpp { using _alias_t = typename AliasProvider::_alias_t; + cte_t(Statement statement): _statement(statement){} + cte_t(const cte_t&) = default; + cte_t(cte_t&&) = default; + cte_t& operator=(const cte_t&) = default; + cte_t& operator=(cte_t&&) = default; + ~cte_t() = default; + Statement _statement; }; @@ -92,7 +99,7 @@ namespace sqlpp }; -// The cte is displayed as AliasProviderName except within the with: +// The cte_t is displayed as AliasProviderName except within the with: // - the with needs the // AliasProviderName AS (ColumnNames) (select/union) // The result row of the select should not have dynamic parts diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp index 6932966e..6992458a 100644 --- a/tests/WithTest.cpp +++ b/tests/WithTest.cpp @@ -34,6 +34,9 @@ MockDb::_serializer_context_t printer; int main() { + const auto t = test::TabBar{}; + + auto x = cte(sqlpp::x).as(select(all_of(t)).from(t)); // to be done return 0; From 256060c2d700892c640e0727d8f58dd34a72b222 Mon Sep 17 00:00:00 2001 From: niXman Date: Wed, 28 Jan 2015 22:54:57 +0200 Subject: [PATCH 060/105] The first working implementation --- examples/CMakeLists.txt | 1 + examples/ppgen.cpp | 93 +++++++++++ include/sqlpp11/ppgen.h | 206 +++++++++++++++++++++++++ include/sqlpp11/ppgen/auto_increment.h | 35 +++++ include/sqlpp11/ppgen/blob.h | 50 ++++++ include/sqlpp11/ppgen/bool.h | 35 +++++ include/sqlpp11/ppgen/character_set.h | 35 +++++ include/sqlpp11/ppgen/comment.h | 35 +++++ include/sqlpp11/ppgen/datetime.h | 35 +++++ include/sqlpp11/ppgen/default.h | 35 +++++ include/sqlpp11/ppgen/engine.h | 35 +++++ include/sqlpp11/ppgen/floating_point.h | 40 +++++ include/sqlpp11/ppgen/index.h | 35 +++++ include/sqlpp11/ppgen/integer.h | 50 ++++++ include/sqlpp11/ppgen/key.h | 35 +++++ include/sqlpp11/ppgen/not_null.h | 35 +++++ include/sqlpp11/ppgen/null.h | 35 +++++ include/sqlpp11/ppgen/primary_key.h | 35 +++++ include/sqlpp11/ppgen/text.h | 35 +++++ include/sqlpp11/ppgen/timestamp.h | 35 +++++ include/sqlpp11/ppgen/unique.h | 35 +++++ include/sqlpp11/ppgen/varchar.h | 35 +++++ include/sqlpp11/ppgen/wrap_seq.h | 38 +++++ 23 files changed, 1038 insertions(+) create mode 100644 examples/ppgen.cpp create mode 100644 include/sqlpp11/ppgen.h create mode 100644 include/sqlpp11/ppgen/auto_increment.h create mode 100644 include/sqlpp11/ppgen/blob.h create mode 100644 include/sqlpp11/ppgen/bool.h create mode 100644 include/sqlpp11/ppgen/character_set.h create mode 100644 include/sqlpp11/ppgen/comment.h create mode 100644 include/sqlpp11/ppgen/datetime.h create mode 100644 include/sqlpp11/ppgen/default.h create mode 100644 include/sqlpp11/ppgen/engine.h create mode 100644 include/sqlpp11/ppgen/floating_point.h create mode 100644 include/sqlpp11/ppgen/index.h create mode 100644 include/sqlpp11/ppgen/integer.h create mode 100644 include/sqlpp11/ppgen/key.h create mode 100644 include/sqlpp11/ppgen/not_null.h create mode 100644 include/sqlpp11/ppgen/null.h create mode 100644 include/sqlpp11/ppgen/primary_key.h create mode 100644 include/sqlpp11/ppgen/text.h create mode 100644 include/sqlpp11/ppgen/timestamp.h create mode 100644 include/sqlpp11/ppgen/unique.h create mode 100644 include/sqlpp11/ppgen/varchar.h create mode 100644 include/sqlpp11/ppgen/wrap_seq.h diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1ab2fd65..60fdd051 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,6 +11,7 @@ build(insert) build(update) build(remove) build(select) +build(ppgen) #find_package(PythonInterp REQUIRED) diff --git a/examples/ppgen.cpp b/examples/ppgen.cpp new file mode 100644 index 00000000..4c4d01a5 --- /dev/null +++ b/examples/ppgen.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if 0 // syntax example +SQLPP_DECLARE_TABLE( + (table, DROP_IF_EXISTS, CREATE_IF_NOT_EXISTS, ENGINE("InnoDB"), CHARACTER_SET("utf-8"), COMMENT("table comments")) + , + (id, int, NOT_NULL, PRIMARY_KEY, AUTO_INCREMENT) + (name, varchar(64), NOT_NULL, INDEX("name_index"), DEFAULT("any name")) + (age, int, NOT_NULL, INDEX("age_index"), UNIQUE, COMMENT("some comments")) +) +#endif + +#include +#include + +#include "MockDb.h" + +SQLPP_DECLARE_TABLE( + (tab_person) + , + (id , int , SQLPP_AUTO_INCREMENT) + (name , varchar(255), SQLPP_NOT_NULL ) + (feature, int , SQLPP_NOT_NULL ) +) + +SQLPP_DECLARE_TABLE( + (tab_feature) + , + (id , int , SQLPP_AUTO_INCREMENT) + (name , varchar(255), SQLPP_NULL ) + (fatal, bool , SQLPP_NOT_NULL ) +) + +int main() { + MockDb db; + tab_person::tab_person p; + tab_feature::tab_feature f; + + 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.name == "loves c++", f.fatal = false)); + + //db(insert_into(f).set(f.name = "loves c++", f.fatal = "false")); + + //db(insert_into(p).set(f.name = "loves c++", f.fatal = false)); + + //db(insert_into(f).set(f.name = "loves c++", p.feature = 7)); + + //db(insert_into(f).set(f.id = 42, f.name = "loves c++", f.fatal = false)); + + //db(insert_into(f).set(f.name = "loves c++")); + + + db(insert_into(f).default_values()); + + auto i = insert_into(p).columns(p.name, p.feature); + i.values.add(p.name = "Roland", p.feature = 1); + i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value); + db(i); + + + auto pi = db.prepare(insert_into(p).set(p.name = parameter(f.name), p.feature = parameter(p.feature))); + pi.params.name = "likes java"; + pi.params.feature = true; + + db(pi); +} diff --git a/include/sqlpp11/ppgen.h b/include/sqlpp11/ppgen.h new file mode 100644 index 00000000..a05a80f7 --- /dev/null +++ b/include/sqlpp11/ppgen.h @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen_h +#define _sqlpp__ppgen_h + +#include + +// enable the Clang support +#if defined(__clang__) && !BOOST_PP_VARIADICS +# undef BOOST_PP_VARIADICS +# define BOOST_PP_VARIADICS 1 +#endif // defined(__clang__) + +// tools +#include + +// table props +#include +#include + +// col props +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// boost.preprocessor +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/***************************************************************************/ +// tools + +#define SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) \ + BOOST_PP_TUPLE_ELEM(0, BOOST_PP_EXPAND table) + +#define SQLPP_DECLARE_TABLE_GET_TABLE_PROPS(table) \ + BOOST_PP_TUPLE_POP_FRONT(BOOST_PP_EXPAND table) + +#define SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(col) \ + BOOST_PP_TUPLE_ELEM(0, col) + +#define SQLPP_DECLARE_TABLE_ENUM_COLUMNS(unused, table, elem) \ + ,table::SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem) + +/***************************************************************************/ +// columns + +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_AUX(unused, size, idx, elem) \ + BOOST_PP_CAT( \ + SQLPP_DECLARE_COLUMN_GEN_TRAITS_ \ + ,BOOST_PP_CAT(SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_, elem) \ + )(elem) \ + BOOST_PP_COMMA_IF(BOOST_PP_LESS(BOOST_PP_ADD(idx, 1), size)) + +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS(props) \ + BOOST_PP_SEQ_FOR_EACH_I( \ + SQLPP_DECLARE_COLUMN_GEN_TRAITS_AUX \ + ,BOOST_PP_TUPLE_SIZE(props) \ + ,BOOST_PP_TUPLE_TO_SEQ(props) \ + ) + +#define SQLPP_DECLARE_COLUMN(unused, data, elem) \ + struct SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem) { \ + struct _alias_t { \ + static constexpr const char _literal[] = \ + BOOST_PP_STRINGIZE(SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem)); \ + using _name_t = sqlpp::make_char_sequence; \ + \ + template \ + struct _member_t { \ + T SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); \ + \ + T& operator()() { return SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); } \ + const T& operator()() const { return SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem); } \ + }; /* struct _member_t */ \ + }; /* struct _alias_t */ \ + \ + using _traits = sqlpp::make_traits< \ + SQLPP_DECLARE_COLUMN_GEN_TRAITS(BOOST_PP_TUPLE_POP_FRONT(elem)) \ + >; \ + \ + }; /* struct SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem) */ + +/***************************************************************************/ +// table props + +#define SQLPP_DECLARE_TABLE_GEN_PROPS_AUX(unused1, unused2, elem) \ + BOOST_PP_CAT( \ + SQLPP_DECLARE_TABLE_GEN_ \ + ,BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_PROC_LAZY_, elem) \ + )(elem) + +#define SQLPP_DECLARE_TABLE_GEN_PROPS(table) \ + BOOST_PP_SEQ_FOR_EACH( \ + SQLPP_DECLARE_TABLE_GEN_PROPS_AUX \ + ,~ \ + ,BOOST_PP_TUPLE_TO_SEQ(BOOST_PP_TUPLE_POP_FRONT(table)) \ + ) + +/***************************************************************************/ +// main + +#define SQLPP_DECLARE_TABLE_IMPL(table, cols) \ + namespace SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) { \ + namespace BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _) { \ + BOOST_PP_SEQ_FOR_EACH( \ + SQLPP_DECLARE_COLUMN \ + ,~ \ + ,cols \ + ) \ + } /* namespace BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _) */ \ + \ + struct SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) \ + : sqlpp::table_t< \ + SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) \ + BOOST_PP_SEQ_FOR_EACH( \ + SQLPP_DECLARE_TABLE_ENUM_COLUMNS \ + ,BOOST_PP_CAT(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table), _) \ + ,cols \ + ) \ + > \ + { \ + BOOST_PP_IF( \ + BOOST_PP_LESS(BOOST_PP_TUPLE_SIZE(table), 2) \ + ,BOOST_PP_TUPLE_EAT() \ + ,SQLPP_DECLARE_TABLE_GEN_PROPS \ + )(BOOST_PP_EXPAND table) \ + \ + struct _alias_t { \ + static constexpr const char _literal[] = \ + BOOST_PP_STRINGIZE(SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table)); \ + using _name_t = sqlpp::make_char_sequence; \ + \ + template \ + struct _member_t { \ + T SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); \ + \ + T& operator()() { return SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); } \ + const T& operator()() const { return SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table); } \ + \ + }; /* struct _member_t */ \ + \ + }; /* struct _alias_t */ \ + \ + }; /* struct SQLPP_DECLARE_TABLE_GET_TABLE_NAME(table) */ \ + \ + } + +/***************************************************************************/ + +#define SQLPP_DECLARE_TABLE(table, cols) \ + SQLPP_DECLARE_TABLE_IMPL( \ + BOOST_PP_CAT(SQLPP_WRAP_SEQUENCE_X table, 0) \ + ,BOOST_PP_CAT(SQLPP_WRAP_SEQUENCE_X cols, 0) \ + ) + +/***************************************************************************/ + +#endif // _sqlpp__ppgen_h diff --git a/include/sqlpp11/ppgen/auto_increment.h b/include/sqlpp11/ppgen/auto_increment.h new file mode 100644 index 00000000..2ecc2cda --- /dev/null +++ b/include/sqlpp11/ppgen/auto_increment.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__auto_increment_h +#define _sqlpp__ppgen__auto_increment_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_AUTO_INCREMENT \ + PROC_SQLPP_AUTO_INCREMENT +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_AUTO_INCREMENT(...) \ + sqlpp::tag::must_not_update + +#endif // _sqlpp__ppgen__auto_increment_h diff --git a/include/sqlpp11/ppgen/blob.h b/include/sqlpp11/ppgen/blob.h new file mode 100644 index 00000000..d8994fc2 --- /dev/null +++ b/include/sqlpp11/ppgen/blob.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__blob_h +#define _sqlpp__ppgen__blob_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_tinyblob \ + PROC_tinyblob +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_tinyblob(...) \ + sqlpp::blob + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_blob \ + PROC_blob +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_blob(...) \ + sqlpp::blob + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_mediumblob \ + PROC_mediumblob +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_mediumblob(...) \ + sqlpp::blob + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_longblob \ + PROC_longblob +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_longblob(...) \ + sqlpp::blob + +#endif // _sqlpp__ppgen__blob_h diff --git a/include/sqlpp11/ppgen/bool.h b/include/sqlpp11/ppgen/bool.h new file mode 100644 index 00000000..62ae4bfc --- /dev/null +++ b/include/sqlpp11/ppgen/bool.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__bool_h +#define _sqlpp__ppgen__bool_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_bool \ + PROC_bool +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_bool(...) \ + sqlpp::boolean + +#endif // _sqlpp__ppgen__bool_h diff --git a/include/sqlpp11/ppgen/character_set.h b/include/sqlpp11/ppgen/character_set.h new file mode 100644 index 00000000..de02ee91 --- /dev/null +++ b/include/sqlpp11/ppgen/character_set.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__character_set_h +#define _sqlpp__ppgen__character_set_h + +#define SQLPP_DECLARE_TABLE_GET_PROC_LAZY_SQLPP_CHARACTER_SET(str) \ + PROC_SQLPP_CHARACTER_SET +#define SQLPP_DECLARE_TABLE_GEN_PROC_SQLPP_CHARACTER_SET(str) \ + [CHARACTER_SET is not implemented] + +#endif // _sqlpp__ppgen__character_set_h diff --git a/include/sqlpp11/ppgen/comment.h b/include/sqlpp11/ppgen/comment.h new file mode 100644 index 00000000..55161c0f --- /dev/null +++ b/include/sqlpp11/ppgen/comment.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__comment_h +#define _sqlpp__ppgen__comment_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_COMMENT(str) \ + PROC_SQLPP_COMMENT +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_COMMENT(str) \ + [COMMENT is not implemented] + +#endif // _sqlpp__ppgen__comment_h diff --git a/include/sqlpp11/ppgen/datetime.h b/include/sqlpp11/ppgen/datetime.h new file mode 100644 index 00000000..c1cc6e73 --- /dev/null +++ b/include/sqlpp11/ppgen/datetime.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__datetime_h +#define _sqlpp__ppgen__datetime_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_datetime \ + PROC_datetime +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_datetime(...) \ + [datetime is not implemented] + +#endif // _sqlpp__ppgen__datetime_h diff --git a/include/sqlpp11/ppgen/default.h b/include/sqlpp11/ppgen/default.h new file mode 100644 index 00000000..8bc60f70 --- /dev/null +++ b/include/sqlpp11/ppgen/default.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__default_h +#define _sqlpp__ppgen__default_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_DEFAULT(value) \ + PROC_SQLPP_DEFAULT +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_DEFAULT(...) \ + [DEFAULT is not implemented] + +#endif // _sqlpp__ppgen__default_h diff --git a/include/sqlpp11/ppgen/engine.h b/include/sqlpp11/ppgen/engine.h new file mode 100644 index 00000000..5b40e881 --- /dev/null +++ b/include/sqlpp11/ppgen/engine.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__engine_h +#define _sqlpp__ppgen__engine_h + +#define SQLPP_DECLARE_TABLE_GET_PROC_LAZY_SQLPP_ENGINE(str) \ + PROC_SQLPP_ENGINE +#define SQLPP_DECLARE_TABLE_GEN_PROC_SQLPP_ENGINE(str) \ + [ENGINE is not implemented] + +#endif // _sqlpp__ppgen__engine_h diff --git a/include/sqlpp11/ppgen/floating_point.h b/include/sqlpp11/ppgen/floating_point.h new file mode 100644 index 00000000..77ab121e --- /dev/null +++ b/include/sqlpp11/ppgen/floating_point.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__floating_point_h +#define _sqlpp__ppgen__floating_point_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_float \ + PROC_float +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_float(...) \ + sqlpp::floating_point + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_double \ + PROC_double +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_double(...) \ + sqlpp::floating_point + +#endif // _sqlpp__ppgen__floating_point_h diff --git a/include/sqlpp11/ppgen/index.h b/include/sqlpp11/ppgen/index.h new file mode 100644 index 00000000..97a886d3 --- /dev/null +++ b/include/sqlpp11/ppgen/index.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__index_h +#define _sqlpp__ppgen__index_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_INDEX(name) \ + PROC_SQLPP_INDEX +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_INDEX(name) \ + [INDEX is not implemented] + +#endif // _sqlpp__ppgen__index_h diff --git a/include/sqlpp11/ppgen/integer.h b/include/sqlpp11/ppgen/integer.h new file mode 100644 index 00000000..934930d0 --- /dev/null +++ b/include/sqlpp11/ppgen/integer.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__integer_h +#define _sqlpp__ppgen__integer_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_tinyint \ + PROC_tinyint +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_tinyint(...) \ + sqlpp::tinyint + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_smallint \ + PROC_smallint +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_smallint(...) \ + sqlpp::smallint + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_int \ + PROC_int +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_int(...) \ + sqlpp::integer + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_bigint \ + PROC_bigint +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_bigint(...) \ + sqlpp::bigint + +#endif // _sqlpp__ppgen__integer_h diff --git a/include/sqlpp11/ppgen/key.h b/include/sqlpp11/ppgen/key.h new file mode 100644 index 00000000..7192b1d9 --- /dev/null +++ b/include/sqlpp11/ppgen/key.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__key_h +#define _sqlpp__ppgen__key_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_KEY(name) \ + PROC_SQLPP_KEY +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_KEY(name) \ + [KEY is not implemented] + +#endif // _sqlpp__ppgen__key_h diff --git a/include/sqlpp11/ppgen/not_null.h b/include/sqlpp11/ppgen/not_null.h new file mode 100644 index 00000000..fadff0db --- /dev/null +++ b/include/sqlpp11/ppgen/not_null.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__not_null_h +#define _sqlpp__ppgen__not_null_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_NOT_NULL \ + PROC_SQLPP_NOT_NULL +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_NOT_NULL(...) \ + sqlpp::tag::require_insert + +#endif // _sqlpp__ppgen__not_null_h diff --git a/include/sqlpp11/ppgen/null.h b/include/sqlpp11/ppgen/null.h new file mode 100644 index 00000000..94269b01 --- /dev/null +++ b/include/sqlpp11/ppgen/null.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__null_h +#define _sqlpp__ppgen__null_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_NULL \ + PROC_SQLPP_NULL +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_NULL(...) \ + sqlpp::tag::can_be_null + +#endif // _sqlpp__ppgen__null_h diff --git a/include/sqlpp11/ppgen/primary_key.h b/include/sqlpp11/ppgen/primary_key.h new file mode 100644 index 00000000..2bf82e05 --- /dev/null +++ b/include/sqlpp11/ppgen/primary_key.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__primary_key_h +#define _sqlpp__ppgen__primary_key_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_PRIMARY_KEY \ + PROC_SQLPP_PRIMARY_KEY +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_PRIMARY_KEY(...) \ + [PRIMARY_KEY is not implemented] + +#endif // _sqlpp__ppgen__primary_key_h diff --git a/include/sqlpp11/ppgen/text.h b/include/sqlpp11/ppgen/text.h new file mode 100644 index 00000000..2880a602 --- /dev/null +++ b/include/sqlpp11/ppgen/text.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__text_h +#define _sqlpp__ppgen__text_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_text \ + PROC_text +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_text(...) \ + sqlpp::text + +#endif // _sqlpp__ppgen__text_h diff --git a/include/sqlpp11/ppgen/timestamp.h b/include/sqlpp11/ppgen/timestamp.h new file mode 100644 index 00000000..6592b88b --- /dev/null +++ b/include/sqlpp11/ppgen/timestamp.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__timestamp_h +#define _sqlpp__ppgen__timestamp_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_timestamp \ + PROC_timestamp +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_timestamp(...) \ + [timestamp is not implemented] + +#endif // _sqlpp__ppgen__timestamp_h diff --git a/include/sqlpp11/ppgen/unique.h b/include/sqlpp11/ppgen/unique.h new file mode 100644 index 00000000..56f83102 --- /dev/null +++ b/include/sqlpp11/ppgen/unique.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__unique_h +#define _sqlpp__ppgen__unique_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_UNIQUE \ + PROC_SQLPP_UNIQUE +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_UNIQUE(...) \ + [UNIQUE is not implemented] + +#endif // _sqlpp__ppgen__unique_h diff --git a/include/sqlpp11/ppgen/varchar.h b/include/sqlpp11/ppgen/varchar.h new file mode 100644 index 00000000..6561c27d --- /dev/null +++ b/include/sqlpp11/ppgen/varchar.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__varchar_h +#define _sqlpp__ppgen__varchar_h + +#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_varchar(str) \ + PROC_varchar +#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_varchar(str) \ + sqlpp::varchar + +#endif // _sqlpp__ppgen__varchar_h diff --git a/include/sqlpp11/ppgen/wrap_seq.h b/include/sqlpp11/ppgen/wrap_seq.h new file mode 100644 index 00000000..741e9a62 --- /dev/null +++ b/include/sqlpp11/ppgen/wrap_seq.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__wrap_seq_h +#define _sqlpp__ppgen__wrap_seq_h + +#define SQLPP_WRAP_SEQUENCE_X(...) \ + ((__VA_ARGS__)) SQLPP_WRAP_SEQUENCE_Y +#define SQLPP_WRAP_SEQUENCE_Y(...) \ + ((__VA_ARGS__)) SQLPP_WRAP_SEQUENCE_X + +#define SQLPP_WRAP_SEQUENCE_X0 +#define SQLPP_WRAP_SEQUENCE_Y0 + +#endif // _sqlpp__ppgen__wrap_seq_h From 2adf529445710bbdd5a86a5c5ba1e3a9a557ee00 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 29 Jan 2015 19:17:24 +0100 Subject: [PATCH 061/105] First with-query compiles --- include/sqlpp11/cte.h | 13 +++++++++++++ include/sqlpp11/type_traits.h | 2 ++ include/sqlpp11/with.h | 32 +++++++++++++++++++++++--------- tests/WithTest.cpp | 3 ++- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 34b33506..86aea573 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -71,6 +71,19 @@ namespace sqlpp template struct cte_t: public member_t>... // FIXME { + using _traits = make_traits; + struct _recursive_traits + { + using _required_ctes = required_ctes_of; + using _provided_ctes = detail::make_type_set_t; + using _required_tables = required_tables_of; + using _provided_tables = detail::type_set; + using _provided_outer_tables = detail::type_set<>; + using _extra_tables = detail::type_set<>; + using _parameters = parameters_of; + using _tags = detail::type_set<>; + }; + using _alias_t = typename AliasProvider::_alias_t; cte_t(Statement statement): _statement(statement){} diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 31f6a68e..e1f0239c 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -126,6 +126,8 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null); SQLPP_VALUE_TRAIT_GENERATOR(null_is_trivial_value); + SQLPP_VALUE_TRAIT_GENERATOR(is_with); + SQLPP_VALUE_TRAIT_GENERATOR(is_cte); SQLPP_VALUE_TRAIT_GENERATOR(is_statement); SQLPP_VALUE_TRAIT_GENERATOR(is_prepared_statement); SQLPP_VALUE_TRAIT_GENERATOR(is_noop); diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 8700641c..63ecf249 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -56,13 +56,12 @@ namespace sqlpp ~with_data_t() = default; std::tuple _expressions; - interpretable_list_t _dynamic_expressions; }; template struct with_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits; using _is_dynamic = is_database; @@ -84,14 +83,14 @@ namespace sqlpp { using _data_t = with_data_t; - _impl_t where; - _impl_t& operator()() { return where; } - const _impl_t& operator()() const { return where; } + _impl_t with; + _impl_t& operator()() { return with; } + const _impl_t& operator()() const { return with; } template - static auto _get_member(T t) -> decltype(t.where) + static auto _get_member(T t) -> decltype(t.with) { - return t.where; + return t.with; } #warning: Need real checks here @@ -102,7 +101,7 @@ namespace sqlpp struct no_with_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; // Data @@ -143,13 +142,28 @@ namespace sqlpp template auto operator()(Statement statement) - -> new_statement_t> + -> new_statement_t> { // FIXME need checks here, e.g. if there is recursion return { statement, _data }; } }; + // Interpreters + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = with_data_t; + + static Context& _(const T& t, Context& context) + { + context << " WITH "; + interpret_tuple(t._expressions, ',', context); + return context; + } + }; + template auto with(Expressions... cte) -> blank_with_t diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp index 6992458a..32b27ed4 100644 --- a/tests/WithTest.cpp +++ b/tests/WithTest.cpp @@ -37,7 +37,8 @@ int main() const auto t = test::TabBar{}; auto x = cte(sqlpp::x).as(select(all_of(t)).from(t)); - // to be done + + db(with(x)(select(x.alpha).from(x).where(true))); return 0; } From 59c5bc8970e7c5a678afc4d2629e64192ded1f93 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 29 Jan 2015 23:32:03 +0100 Subject: [PATCH 062/105] Wrapped code generator example with a check for boost-1.56+ --- examples/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 60fdd051..e2642b87 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,13 @@ build(insert) build(update) build(remove) build(select) -build(ppgen) +find_package(Boost 1.56) +if(Boost_FOUND) + MESSAGE(${Boost_INCLUDE_DIRS}) + include_directories(${Boost_INCLUDE_DIRS}) + build(ppgen) +endif() + #find_package(PythonInterp REQUIRED) From 2b7d1ad54a10314e148d3759ad0191564e12ce6a Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 31 Jan 2015 01:26:18 +0200 Subject: [PATCH 063/105] BOOST_PP_TUPLE_POP_FRONT() added & files reorganized --- include/sqlpp11/ppgen.h | 45 ++++++++++--------- .../ppgen/{ => colops}/auto_increment.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/blob.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/bool.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/comment.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/datetime.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/default.h | 6 +-- .../ppgen/{ => colops}/floating_point.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/index.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/integer.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/key.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/not_null.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/null.h | 6 +-- .../sqlpp11/ppgen/{ => colops}/primary_key.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/text.h | 6 +-- .../sqlpp11/ppgen/{ => colops}/timestamp.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/unique.h | 6 +-- include/sqlpp11/ppgen/{ => colops}/varchar.h | 6 +-- .../ppgen/{ => tblops}/character_set.h | 6 +-- include/sqlpp11/ppgen/tblops/comment.h | 35 +++++++++++++++ include/sqlpp11/ppgen/tblops/default.h | 35 +++++++++++++++ include/sqlpp11/ppgen/{ => tblops}/engine.h | 6 +-- include/sqlpp11/ppgen/tools/tuple_pop_front.h | 44 ++++++++++++++++++ include/sqlpp11/ppgen/{ => tools}/wrap_seq.h | 6 +-- 24 files changed, 197 insertions(+), 82 deletions(-) rename include/sqlpp11/ppgen/{ => colops}/auto_increment.h (91%) rename include/sqlpp11/ppgen/{ => colops}/blob.h (94%) rename include/sqlpp11/ppgen/{ => colops}/bool.h (92%) rename include/sqlpp11/ppgen/{ => colops}/comment.h (92%) rename include/sqlpp11/ppgen/{ => colops}/datetime.h (92%) rename include/sqlpp11/ppgen/{ => colops}/default.h (92%) rename include/sqlpp11/ppgen/{ => colops}/floating_point.h (92%) rename include/sqlpp11/ppgen/{ => colops}/index.h (92%) rename include/sqlpp11/ppgen/{ => colops}/integer.h (94%) rename include/sqlpp11/ppgen/{ => colops}/key.h (93%) rename include/sqlpp11/ppgen/{ => colops}/not_null.h (92%) rename include/sqlpp11/ppgen/{ => colops}/null.h (93%) rename include/sqlpp11/ppgen/{ => colops}/primary_key.h (92%) rename include/sqlpp11/ppgen/{ => colops}/text.h (92%) rename include/sqlpp11/ppgen/{ => colops}/timestamp.h (92%) rename include/sqlpp11/ppgen/{ => colops}/unique.h (92%) rename include/sqlpp11/ppgen/{ => colops}/varchar.h (92%) rename include/sqlpp11/ppgen/{ => tblops}/character_set.h (91%) create mode 100644 include/sqlpp11/ppgen/tblops/comment.h create mode 100644 include/sqlpp11/ppgen/tblops/default.h rename include/sqlpp11/ppgen/{ => tblops}/engine.h (92%) create mode 100644 include/sqlpp11/ppgen/tools/tuple_pop_front.h rename include/sqlpp11/ppgen/{ => tools}/wrap_seq.h (92%) diff --git a/include/sqlpp11/ppgen.h b/include/sqlpp11/ppgen.h index a05a80f7..2b553e45 100644 --- a/include/sqlpp11/ppgen.h +++ b/include/sqlpp11/ppgen.h @@ -36,29 +36,30 @@ #endif // defined(__clang__) // tools -#include +#include +#include // table props -#include -#include +#include +#include // col props -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // boost.preprocessor #include @@ -81,7 +82,7 @@ BOOST_PP_TUPLE_ELEM(0, BOOST_PP_EXPAND table) #define SQLPP_DECLARE_TABLE_GET_TABLE_PROPS(table) \ - BOOST_PP_TUPLE_POP_FRONT(BOOST_PP_EXPAND table) + SQLPP_BOOST_PP_TUPLE_POP_FRONT(BOOST_PP_EXPAND table) #define SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(col) \ BOOST_PP_TUPLE_ELEM(0, col) @@ -123,7 +124,7 @@ }; /* struct _alias_t */ \ \ using _traits = sqlpp::make_traits< \ - SQLPP_DECLARE_COLUMN_GEN_TRAITS(BOOST_PP_TUPLE_POP_FRONT(elem)) \ + SQLPP_DECLARE_COLUMN_GEN_TRAITS(SQLPP_BOOST_PP_TUPLE_POP_FRONT(elem)) \ >; \ \ }; /* struct SQLPP_DECLARE_COLUMN_GET_COLUMN_NAME(elem) */ @@ -141,7 +142,7 @@ BOOST_PP_SEQ_FOR_EACH( \ SQLPP_DECLARE_TABLE_GEN_PROPS_AUX \ ,~ \ - ,BOOST_PP_TUPLE_TO_SEQ(BOOST_PP_TUPLE_POP_FRONT(table)) \ + ,BOOST_PP_TUPLE_TO_SEQ(SQLPP_BOOST_PP_TUPLE_POP_FRONT(table)) \ ) /***************************************************************************/ diff --git a/include/sqlpp11/ppgen/auto_increment.h b/include/sqlpp11/ppgen/colops/auto_increment.h similarity index 91% rename from include/sqlpp11/ppgen/auto_increment.h rename to include/sqlpp11/ppgen/colops/auto_increment.h index 2ecc2cda..7f88a5ec 100644 --- a/include/sqlpp11/ppgen/auto_increment.h +++ b/include/sqlpp11/ppgen/colops/auto_increment.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__auto_increment_h -#define _sqlpp__ppgen__auto_increment_h +#ifndef _sqlpp__ppgen__colops__auto_increment_h +#define _sqlpp__ppgen__colops__auto_increment_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_AUTO_INCREMENT \ PROC_SQLPP_AUTO_INCREMENT #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_AUTO_INCREMENT(...) \ sqlpp::tag::must_not_update -#endif // _sqlpp__ppgen__auto_increment_h +#endif // _sqlpp__ppgen__colops__auto_increment_h diff --git a/include/sqlpp11/ppgen/blob.h b/include/sqlpp11/ppgen/colops/blob.h similarity index 94% rename from include/sqlpp11/ppgen/blob.h rename to include/sqlpp11/ppgen/colops/blob.h index d8994fc2..26c124e6 100644 --- a/include/sqlpp11/ppgen/blob.h +++ b/include/sqlpp11/ppgen/colops/blob.h @@ -24,8 +24,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__blob_h -#define _sqlpp__ppgen__blob_h +#ifndef _sqlpp__ppgen__colops__blob_h +#define _sqlpp__ppgen__colops__blob_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_tinyblob \ PROC_tinyblob @@ -47,4 +47,4 @@ #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_longblob(...) \ sqlpp::blob -#endif // _sqlpp__ppgen__blob_h +#endif // _sqlpp__ppgen__colops__blob_h diff --git a/include/sqlpp11/ppgen/bool.h b/include/sqlpp11/ppgen/colops/bool.h similarity index 92% rename from include/sqlpp11/ppgen/bool.h rename to include/sqlpp11/ppgen/colops/bool.h index 62ae4bfc..08521bd3 100644 --- a/include/sqlpp11/ppgen/bool.h +++ b/include/sqlpp11/ppgen/colops/bool.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__bool_h -#define _sqlpp__ppgen__bool_h +#ifndef _sqlpp__ppgen__colops__bool_h +#define _sqlpp__ppgen__colops__bool_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_bool \ PROC_bool #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_bool(...) \ sqlpp::boolean -#endif // _sqlpp__ppgen__bool_h +#endif // _sqlpp__ppgen__colops__bool_h diff --git a/include/sqlpp11/ppgen/comment.h b/include/sqlpp11/ppgen/colops/comment.h similarity index 92% rename from include/sqlpp11/ppgen/comment.h rename to include/sqlpp11/ppgen/colops/comment.h index 55161c0f..f019b732 100644 --- a/include/sqlpp11/ppgen/comment.h +++ b/include/sqlpp11/ppgen/colops/comment.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__comment_h -#define _sqlpp__ppgen__comment_h +#ifndef _sqlpp__ppgen__colops__comment_h +#define _sqlpp__ppgen__colops__comment_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_COMMENT(str) \ PROC_SQLPP_COMMENT #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_COMMENT(str) \ [COMMENT is not implemented] -#endif // _sqlpp__ppgen__comment_h +#endif // _sqlpp__ppgen__colops__comment_h diff --git a/include/sqlpp11/ppgen/datetime.h b/include/sqlpp11/ppgen/colops/datetime.h similarity index 92% rename from include/sqlpp11/ppgen/datetime.h rename to include/sqlpp11/ppgen/colops/datetime.h index c1cc6e73..aec6bb04 100644 --- a/include/sqlpp11/ppgen/datetime.h +++ b/include/sqlpp11/ppgen/colops/datetime.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__datetime_h -#define _sqlpp__ppgen__datetime_h +#ifndef _sqlpp__ppgen__colops__datetime_h +#define _sqlpp__ppgen__colops__datetime_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_datetime \ PROC_datetime #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_datetime(...) \ [datetime is not implemented] -#endif // _sqlpp__ppgen__datetime_h +#endif // _sqlpp__ppgen__colops__datetime_h diff --git a/include/sqlpp11/ppgen/default.h b/include/sqlpp11/ppgen/colops/default.h similarity index 92% rename from include/sqlpp11/ppgen/default.h rename to include/sqlpp11/ppgen/colops/default.h index 8bc60f70..b7fbdeeb 100644 --- a/include/sqlpp11/ppgen/default.h +++ b/include/sqlpp11/ppgen/colops/default.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__default_h -#define _sqlpp__ppgen__default_h +#ifndef _sqlpp__ppgen__colops__default_h +#define _sqlpp__ppgen__colops__default_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_DEFAULT(value) \ PROC_SQLPP_DEFAULT #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_DEFAULT(...) \ [DEFAULT is not implemented] -#endif // _sqlpp__ppgen__default_h +#endif // _sqlpp__ppgen__colops__default_h diff --git a/include/sqlpp11/ppgen/floating_point.h b/include/sqlpp11/ppgen/colops/floating_point.h similarity index 92% rename from include/sqlpp11/ppgen/floating_point.h rename to include/sqlpp11/ppgen/colops/floating_point.h index 77ab121e..ea25560c 100644 --- a/include/sqlpp11/ppgen/floating_point.h +++ b/include/sqlpp11/ppgen/colops/floating_point.h @@ -24,8 +24,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__floating_point_h -#define _sqlpp__ppgen__floating_point_h +#ifndef _sqlpp__ppgen__colops__floating_point_h +#define _sqlpp__ppgen__colops__floating_point_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_float \ PROC_float @@ -37,4 +37,4 @@ #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_double(...) \ sqlpp::floating_point -#endif // _sqlpp__ppgen__floating_point_h +#endif // _sqlpp__ppgen__colops__floating_point_h diff --git a/include/sqlpp11/ppgen/index.h b/include/sqlpp11/ppgen/colops/index.h similarity index 92% rename from include/sqlpp11/ppgen/index.h rename to include/sqlpp11/ppgen/colops/index.h index 97a886d3..37a1fee1 100644 --- a/include/sqlpp11/ppgen/index.h +++ b/include/sqlpp11/ppgen/colops/index.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__index_h -#define _sqlpp__ppgen__index_h +#ifndef _sqlpp__ppgen__colops__index_h +#define _sqlpp__ppgen__colops__index_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_INDEX(name) \ PROC_SQLPP_INDEX #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_INDEX(name) \ [INDEX is not implemented] -#endif // _sqlpp__ppgen__index_h +#endif // _sqlpp__ppgen__colops__index_h diff --git a/include/sqlpp11/ppgen/integer.h b/include/sqlpp11/ppgen/colops/integer.h similarity index 94% rename from include/sqlpp11/ppgen/integer.h rename to include/sqlpp11/ppgen/colops/integer.h index 934930d0..d913e441 100644 --- a/include/sqlpp11/ppgen/integer.h +++ b/include/sqlpp11/ppgen/colops/integer.h @@ -24,8 +24,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__integer_h -#define _sqlpp__ppgen__integer_h +#ifndef _sqlpp__ppgen__colops__integer_h +#define _sqlpp__ppgen__colops__integer_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_tinyint \ PROC_tinyint @@ -47,4 +47,4 @@ #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_bigint(...) \ sqlpp::bigint -#endif // _sqlpp__ppgen__integer_h +#endif // _sqlpp__ppgen__colops__integer_h diff --git a/include/sqlpp11/ppgen/key.h b/include/sqlpp11/ppgen/colops/key.h similarity index 93% rename from include/sqlpp11/ppgen/key.h rename to include/sqlpp11/ppgen/colops/key.h index 7192b1d9..1791c30c 100644 --- a/include/sqlpp11/ppgen/key.h +++ b/include/sqlpp11/ppgen/colops/key.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__key_h -#define _sqlpp__ppgen__key_h +#ifndef _sqlpp__ppgen__colops__key_h +#define _sqlpp__ppgen__colops__key_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_KEY(name) \ PROC_SQLPP_KEY #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_KEY(name) \ [KEY is not implemented] -#endif // _sqlpp__ppgen__key_h +#endif // _sqlpp__ppgen__colops__key_h diff --git a/include/sqlpp11/ppgen/not_null.h b/include/sqlpp11/ppgen/colops/not_null.h similarity index 92% rename from include/sqlpp11/ppgen/not_null.h rename to include/sqlpp11/ppgen/colops/not_null.h index fadff0db..0a2b029e 100644 --- a/include/sqlpp11/ppgen/not_null.h +++ b/include/sqlpp11/ppgen/colops/not_null.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__not_null_h -#define _sqlpp__ppgen__not_null_h +#ifndef _sqlpp__ppgen__colops__not_null_h +#define _sqlpp__ppgen__colops__not_null_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_NOT_NULL \ PROC_SQLPP_NOT_NULL #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_NOT_NULL(...) \ sqlpp::tag::require_insert -#endif // _sqlpp__ppgen__not_null_h +#endif // _sqlpp__ppgen__colops__not_null_h diff --git a/include/sqlpp11/ppgen/null.h b/include/sqlpp11/ppgen/colops/null.h similarity index 93% rename from include/sqlpp11/ppgen/null.h rename to include/sqlpp11/ppgen/colops/null.h index 94269b01..bd7d33d6 100644 --- a/include/sqlpp11/ppgen/null.h +++ b/include/sqlpp11/ppgen/colops/null.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__null_h -#define _sqlpp__ppgen__null_h +#ifndef _sqlpp__ppgen__colops__null_h +#define _sqlpp__ppgen__colops__null_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_NULL \ PROC_SQLPP_NULL #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_NULL(...) \ sqlpp::tag::can_be_null -#endif // _sqlpp__ppgen__null_h +#endif // _sqlpp__ppgen__colops__null_h diff --git a/include/sqlpp11/ppgen/primary_key.h b/include/sqlpp11/ppgen/colops/primary_key.h similarity index 92% rename from include/sqlpp11/ppgen/primary_key.h rename to include/sqlpp11/ppgen/colops/primary_key.h index 2bf82e05..916f752b 100644 --- a/include/sqlpp11/ppgen/primary_key.h +++ b/include/sqlpp11/ppgen/colops/primary_key.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__primary_key_h -#define _sqlpp__ppgen__primary_key_h +#ifndef _sqlpp__ppgen__colops__primary_key_h +#define _sqlpp__ppgen__colops__primary_key_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_PRIMARY_KEY \ PROC_SQLPP_PRIMARY_KEY #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_PRIMARY_KEY(...) \ [PRIMARY_KEY is not implemented] -#endif // _sqlpp__ppgen__primary_key_h +#endif // _sqlpp__ppgen__colops__primary_key_h diff --git a/include/sqlpp11/ppgen/text.h b/include/sqlpp11/ppgen/colops/text.h similarity index 92% rename from include/sqlpp11/ppgen/text.h rename to include/sqlpp11/ppgen/colops/text.h index 2880a602..7329a986 100644 --- a/include/sqlpp11/ppgen/text.h +++ b/include/sqlpp11/ppgen/colops/text.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__text_h -#define _sqlpp__ppgen__text_h +#ifndef _sqlpp__ppgen__colops__text_h +#define _sqlpp__ppgen__colops__text_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_text \ PROC_text #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_text(...) \ sqlpp::text -#endif // _sqlpp__ppgen__text_h +#endif // _sqlpp__ppgen__colops__text_h diff --git a/include/sqlpp11/ppgen/timestamp.h b/include/sqlpp11/ppgen/colops/timestamp.h similarity index 92% rename from include/sqlpp11/ppgen/timestamp.h rename to include/sqlpp11/ppgen/colops/timestamp.h index 6592b88b..130e005b 100644 --- a/include/sqlpp11/ppgen/timestamp.h +++ b/include/sqlpp11/ppgen/colops/timestamp.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__timestamp_h -#define _sqlpp__ppgen__timestamp_h +#ifndef _sqlpp__ppgen__colops__timestamp_h +#define _sqlpp__ppgen__colops__timestamp_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_timestamp \ PROC_timestamp #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_timestamp(...) \ [timestamp is not implemented] -#endif // _sqlpp__ppgen__timestamp_h +#endif // _sqlpp__ppgen__colops__timestamp_h diff --git a/include/sqlpp11/ppgen/unique.h b/include/sqlpp11/ppgen/colops/unique.h similarity index 92% rename from include/sqlpp11/ppgen/unique.h rename to include/sqlpp11/ppgen/colops/unique.h index 56f83102..34b43792 100644 --- a/include/sqlpp11/ppgen/unique.h +++ b/include/sqlpp11/ppgen/colops/unique.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__unique_h -#define _sqlpp__ppgen__unique_h +#ifndef _sqlpp__ppgen__colops__unique_h +#define _sqlpp__ppgen__colops__unique_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_SQLPP_UNIQUE \ PROC_SQLPP_UNIQUE #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_SQLPP_UNIQUE(...) \ [UNIQUE is not implemented] -#endif // _sqlpp__ppgen__unique_h +#endif // _sqlpp__ppgen__colops__unique_h diff --git a/include/sqlpp11/ppgen/varchar.h b/include/sqlpp11/ppgen/colops/varchar.h similarity index 92% rename from include/sqlpp11/ppgen/varchar.h rename to include/sqlpp11/ppgen/colops/varchar.h index 6561c27d..c4de3235 100644 --- a/include/sqlpp11/ppgen/varchar.h +++ b/include/sqlpp11/ppgen/colops/varchar.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__varchar_h -#define _sqlpp__ppgen__varchar_h +#ifndef _sqlpp__ppgen__colops__varchar_h +#define _sqlpp__ppgen__colops__varchar_h #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_varchar(str) \ PROC_varchar #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_varchar(str) \ sqlpp::varchar -#endif // _sqlpp__ppgen__varchar_h +#endif // _sqlpp__ppgen__colops__varchar_h diff --git a/include/sqlpp11/ppgen/character_set.h b/include/sqlpp11/ppgen/tblops/character_set.h similarity index 91% rename from include/sqlpp11/ppgen/character_set.h rename to include/sqlpp11/ppgen/tblops/character_set.h index de02ee91..8b5026b2 100644 --- a/include/sqlpp11/ppgen/character_set.h +++ b/include/sqlpp11/ppgen/tblops/character_set.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__character_set_h -#define _sqlpp__ppgen__character_set_h +#ifndef _sqlpp__ppgen__tblops__character_set_h +#define _sqlpp__ppgen__tblops__character_set_h #define SQLPP_DECLARE_TABLE_GET_PROC_LAZY_SQLPP_CHARACTER_SET(str) \ PROC_SQLPP_CHARACTER_SET #define SQLPP_DECLARE_TABLE_GEN_PROC_SQLPP_CHARACTER_SET(str) \ [CHARACTER_SET is not implemented] -#endif // _sqlpp__ppgen__character_set_h +#endif // _sqlpp__ppgen__tblops__character_set_h diff --git a/include/sqlpp11/ppgen/tblops/comment.h b/include/sqlpp11/ppgen/tblops/comment.h new file mode 100644 index 00000000..6df2784b --- /dev/null +++ b/include/sqlpp11/ppgen/tblops/comment.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__tblops__comment_h +#define _sqlpp__ppgen__tblops__comment_h + +#define SQLPP_DECLARE_TABLE_GET_TRAITS_LAZY_SQLPP_COMMENT(str) \ + PROC_SQLPP_COMMENT +#define SQLPP_DECLARE_TABLE_GEN_TRAITS_PROC_SQLPP_COMMENT(str) \ + [COMMENT is not implemented] + +#endif // _sqlpp__ppgen__tblops__comment_h diff --git a/include/sqlpp11/ppgen/tblops/default.h b/include/sqlpp11/ppgen/tblops/default.h new file mode 100644 index 00000000..7e70bf8f --- /dev/null +++ b/include/sqlpp11/ppgen/tblops/default.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014-2015, niXman (i dot nixman dog gmail dot com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _sqlpp__ppgen__tblops__default_h +#define _sqlpp__ppgen__tblops__default_h + +#define SQLPP_DECLARE_TABLE_GET_TRAITS_LAZY_SQLPP_DEFAULT(value) \ + PROC_SQLPP_DEFAULT +#define SQLPP_DECLARE_TABLE_GEN_TRAITS_PROC_SQLPP_DEFAULT(...) \ + [DEFAULT is not implemented] + +#endif // _sqlpp__ppgen__tblops__default_h diff --git a/include/sqlpp11/ppgen/engine.h b/include/sqlpp11/ppgen/tblops/engine.h similarity index 92% rename from include/sqlpp11/ppgen/engine.h rename to include/sqlpp11/ppgen/tblops/engine.h index 5b40e881..24b2e8aa 100644 --- a/include/sqlpp11/ppgen/engine.h +++ b/include/sqlpp11/ppgen/tblops/engine.h @@ -24,12 +24,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__engine_h -#define _sqlpp__ppgen__engine_h +#ifndef _sqlpp__ppgen__tblops__engine_h +#define _sqlpp__ppgen__tblops__engine_h #define SQLPP_DECLARE_TABLE_GET_PROC_LAZY_SQLPP_ENGINE(str) \ PROC_SQLPP_ENGINE #define SQLPP_DECLARE_TABLE_GEN_PROC_SQLPP_ENGINE(str) \ [ENGINE is not implemented] -#endif // _sqlpp__ppgen__engine_h +#endif // _sqlpp__ppgen__tblops__engine_h diff --git a/include/sqlpp11/ppgen/tools/tuple_pop_front.h b/include/sqlpp11/ppgen/tools/tuple_pop_front.h new file mode 100644 index 00000000..c958fb89 --- /dev/null +++ b/include/sqlpp11/ppgen/tools/tuple_pop_front.h @@ -0,0 +1,44 @@ +/* ************************************************************************** + * * + * (C) Copyright Edward Diener 2013. + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * * + ************************************************************************** */ + +/* See http://www.boost.org for most recent version. */ + +# ifndef SQLPP_BOOST_PREPROCESSOR_TUPLE_POP_FRONT_HPP +# define SQLPP_BOOST_PREPROCESSOR_TUPLE_POP_FRONT_HPP + +# include + +# if BOOST_PP_VARIADICS + +# include +# include +# include +# include +# include +# include + + +/* BOOST_PP_TUPLE_POP_FRONT */ +# define SQLPP_BOOST_PP_TUPLE_POP_FRONT(tuple) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_GREATER(BOOST_PP_TUPLE_SIZE(tuple),1), \ + SQLPP_BOOST_PP_TUPLE_POP_FRONT_EXEC, \ + SQLPP_BOOST_PP_TUPLE_POP_FRONT_RETURN \ + ) \ + (tuple) + +# define SQLPP_BOOST_PP_TUPLE_POP_FRONT_EXEC(tuple) \ + BOOST_PP_ARRAY_TO_TUPLE(BOOST_PP_ARRAY_POP_FRONT(BOOST_PP_TUPLE_TO_ARRAY(tuple))) + +# define SQLPP_BOOST_PP_TUPLE_POP_FRONT_RETURN(tuple) tuple + +# endif // BOOST_PP_VARIADICS + +# endif // SQLPP_BOOST_PREPROCESSOR_TUPLE_POP_FRONT_HPP diff --git a/include/sqlpp11/ppgen/wrap_seq.h b/include/sqlpp11/ppgen/tools/wrap_seq.h similarity index 92% rename from include/sqlpp11/ppgen/wrap_seq.h rename to include/sqlpp11/ppgen/tools/wrap_seq.h index 741e9a62..9f9451f9 100644 --- a/include/sqlpp11/ppgen/wrap_seq.h +++ b/include/sqlpp11/ppgen/tools/wrap_seq.h @@ -24,8 +24,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _sqlpp__ppgen__wrap_seq_h -#define _sqlpp__ppgen__wrap_seq_h +#ifndef _sqlpp__ppgen__tools__wrap_seq_h +#define _sqlpp__ppgen__tools__wrap_seq_h #define SQLPP_WRAP_SEQUENCE_X(...) \ ((__VA_ARGS__)) SQLPP_WRAP_SEQUENCE_Y @@ -35,4 +35,4 @@ #define SQLPP_WRAP_SEQUENCE_X0 #define SQLPP_WRAP_SEQUENCE_Y0 -#endif // _sqlpp__ppgen__wrap_seq_h +#endif // _sqlpp__ppgen__tools__wrap_seq_h From 504bf961a622328b287561e6c303bfc24db6203a Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 31 Jan 2015 01:36:39 +0200 Subject: [PATCH 064/105] fix for previous commit --- examples/CMakeLists.txt | 2 +- include/sqlpp11/ppgen.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e2642b87..1746d99e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ build(insert) build(update) build(remove) build(select) -find_package(Boost 1.56) +find_package(Boost 1.54) if(Boost_FOUND) MESSAGE(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) diff --git a/include/sqlpp11/ppgen.h b/include/sqlpp11/ppgen.h index 2b553e45..50141bc1 100644 --- a/include/sqlpp11/ppgen.h +++ b/include/sqlpp11/ppgen.h @@ -72,7 +72,6 @@ #include #include #include -#include #include /***************************************************************************/ From df0429058cae84f41106af328b41fc491aa91766 Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 31 Jan 2015 16:05:53 +0200 Subject: [PATCH 065/105] boost.preprocessor hack & some cosmetic fixes --- .travis.yml | 8 +++++++- examples/CMakeLists.txt | 2 +- examples/ppgen.cpp | 14 ++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39ee5821..608e8985 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,11 +15,17 @@ notifications: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi + - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8 libboost-dev-all; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi install: + - git clone https://github.com/boostorg/preprocessor.git + - cd preprocessor + - git checkout tags/boost-1.50.0 + - cp -rf include/boost/* /usr/include/boost/ + - ls -l /usr/include/boost/preprocessor/tuple + - sed 's|104600|105000|' -i /usr/include/boost/version.hpp - "mkdir -p $TRAVIS_BUILD_DIR/build/scripts" - "cd $TRAVIS_BUILD_DIR/build/scripts" - "cmake $TRAVIS_BUILD_DIR" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1746d99e..4db91ca9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ build(insert) build(update) build(remove) build(select) -find_package(Boost 1.54) +find_package(Boost 1.50) if(Boost_FOUND) MESSAGE(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) diff --git a/examples/ppgen.cpp b/examples/ppgen.cpp index 4c4d01a5..68889893 100644 --- a/examples/ppgen.cpp +++ b/examples/ppgen.cpp @@ -26,11 +26,17 @@ #if 0 // syntax example SQLPP_DECLARE_TABLE( - (table, DROP_IF_EXISTS, CREATE_IF_NOT_EXISTS, ENGINE("InnoDB"), CHARACTER_SET("utf-8"), COMMENT("table comments")) + (table, \ + SQLPP_DROP_IF_EXISTS \ + ,SQLPP_CREATE_IF_NOT_EXISTS \ + ,SQLPP_ENGINE("InnoDB") \ + ,SQLPP_CHARACTER_SET("utf-8") \ + ,SQLPP_COMMENT("table comments") \ + ) , - (id, int, NOT_NULL, PRIMARY_KEY, AUTO_INCREMENT) - (name, varchar(64), NOT_NULL, INDEX("name_index"), DEFAULT("any name")) - (age, int, NOT_NULL, INDEX("age_index"), UNIQUE, COMMENT("some comments")) + (id, int, SQLPP_NOT_NULL, SQLPP_PRIMARY_KEY, SQLPP_AUTO_INCREMENT) + (name, varchar(64), SQLPP_NOT_NULL, SQLPP_INDEX("name_index"), SQLPP_DEFAULT("any name")) + (age, int, SQLPP_NOT_NULL, SQLPP_INDEX("age_index"), SQLPP_UNIQUE, SQLPP_COMMENT("some comments")) ) #endif From ed5c123c977ff1cf2a053c299590e115eeef1cac Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 31 Jan 2015 16:40:40 +0200 Subject: [PATCH 066/105] travis.ci configuration testing... --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 608e8985..087e20e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ notifications: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8 libboost-dev-all; fi + - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8 libboost-dev; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi From 76032093e151cb1e853022faae838ded0cecd045 Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 31 Jan 2015 16:44:47 +0200 Subject: [PATCH 067/105] travis.ci configuration testing... --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 087e20e8..9e47f122 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ install: - git clone https://github.com/boostorg/preprocessor.git - cd preprocessor - git checkout tags/boost-1.50.0 - - cp -rf include/boost/* /usr/include/boost/ + - sudo cp -rf include/boost/* /usr/include/boost/ - ls -l /usr/include/boost/preprocessor/tuple - sed 's|104600|105000|' -i /usr/include/boost/version.hpp - "mkdir -p $TRAVIS_BUILD_DIR/build/scripts" From e88e7a2050b5c2335b765ae1ae6ed7ddb4f0168a Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 31 Jan 2015 16:47:40 +0200 Subject: [PATCH 068/105] travis.ci configuration testing... --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9e47f122..7048167d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ install: - git checkout tags/boost-1.50.0 - sudo cp -rf include/boost/* /usr/include/boost/ - ls -l /usr/include/boost/preprocessor/tuple - - sed 's|104600|105000|' -i /usr/include/boost/version.hpp + - sudo sed 's|104600|105000|' -i /usr/include/boost/version.hpp - "mkdir -p $TRAVIS_BUILD_DIR/build/scripts" - "cd $TRAVIS_BUILD_DIR/build/scripts" - "cmake $TRAVIS_BUILD_DIR" From b8ca8c467151265b3baccdb5c2fdd6d4f9573149 Mon Sep 17 00:00:00 2001 From: niXman Date: Sat, 31 Jan 2015 16:51:36 +0200 Subject: [PATCH 069/105] revert travis.ci changes --- .travis.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7048167d..39ee5821 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,17 +15,11 @@ notifications: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8 libboost-dev; fi + - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi install: - - git clone https://github.com/boostorg/preprocessor.git - - cd preprocessor - - git checkout tags/boost-1.50.0 - - sudo cp -rf include/boost/* /usr/include/boost/ - - ls -l /usr/include/boost/preprocessor/tuple - - sudo sed 's|104600|105000|' -i /usr/include/boost/version.hpp - "mkdir -p $TRAVIS_BUILD_DIR/build/scripts" - "cd $TRAVIS_BUILD_DIR/build/scripts" - "cmake $TRAVIS_BUILD_DIR" From 42757b44797ddfd70b4a6f185064aba8544f538a Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 31 Jan 2015 16:06:01 +0100 Subject: [PATCH 070/105] Adding boost to travis box --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 39ee5821..6306825a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ notifications: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update + - sudo apt-get libboost-dev - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi From d6acf0cfb4269332c3805ecff197c2f981854151 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 31 Jan 2015 16:17:01 +0100 Subject: [PATCH 071/105] Still trying to install boost headers --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6306825a..7d79758f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ notifications: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - sudo apt-get libboost-dev + - sudo apt-get install libboost-dev - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi From ef215390621d6f8a2f2fbda01456e0382a0b528a Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 31 Jan 2015 16:27:47 +0100 Subject: [PATCH 072/105] Adjusted CMakeLists to accept boost-1.46. That's what travis is currently using. --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4db91ca9..6f386544 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ build(insert) build(update) build(remove) build(select) -find_package(Boost 1.50) +find_package(Boost 1.46) if(Boost_FOUND) MESSAGE(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) From 8bdb3e953d71ba9de83ecad185f34b1a5956a89e Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 31 Jan 2015 16:47:59 +0100 Subject: [PATCH 073/105] boost-1.50 is required, trying to figure out which versions are available at travis Might have to install headers manually --- .travis.yml | 2 +- examples/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d79758f..dbaf7c45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ notifications: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - sudo apt-get install libboost-dev + - sudo apt-cache search libboost - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6f386544..4db91ca9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ build(insert) build(update) build(remove) build(select) -find_package(Boost 1.46) +find_package(Boost 1.50) if(Boost_FOUND) MESSAGE(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) From 36a6837077b10ba0910b2f61fc3c75771c447533 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 31 Jan 2015 17:15:14 +0100 Subject: [PATCH 074/105] travis: installing boost-1.50 headers "manually" --- .travis.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbaf7c45..24420177 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,13 +13,20 @@ notifications: on_failure: always before_install: + # install boost 1.50 (headers only), travis currently offers 1.46 and 1.48 + - wget http://sourceforge.net/projects/boost/files/boost/1.50.0/boost_1_50_0.tar.bz2/download -O /tmp/boost.tar.bz2 + - mkdir -p temp + - cd temp + - tar jxf /tmp/boost.tar.bz2 boost_1_50_0/boost # extract headers only + - sudo mkdir -p /usr/local/include/ + - sudo ln -s $PWD/boost_1_50_0/boost /usr/local/include + - cd .. + #install g++-4.8 - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update - - sudo apt-cache search libboost - if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi - install: - "mkdir -p $TRAVIS_BUILD_DIR/build/scripts" - "cd $TRAVIS_BUILD_DIR/build/scripts" From aa9c8dcfce406527d16b059d7444892d536b39ad Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 7 Feb 2015 14:42:29 +0100 Subject: [PATCH 075/105] A few FIXME's regarding remaining stuff for with clauses and ctes --- include/sqlpp11/cte.h | 7 ++++++- include/sqlpp11/with.h | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 86aea573..fd40f789 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -69,7 +69,7 @@ namespace sqlpp using make_cte_t = typename make_cte_impl>::type; template - struct cte_t: public member_t>... // FIXME + struct cte_t: public member_t>... { using _traits = make_traits; struct _recursive_traits @@ -84,6 +84,9 @@ namespace sqlpp using _tags = detail::type_set<>; }; + // FIXME: need a union_distinct and union_all here + // unions can depend on the cte itself In that case the cte is recursive. + using _alias_t = typename AliasProvider::_alias_t; cte_t(Statement statement): _statement(statement){} @@ -124,6 +127,8 @@ namespace sqlpp -> make_cte_t { // FIXME: Need to check stuff here. + // e.g. make sure that the statement does not require this a cte of this name (other ctes are allowed) + // make sure that the statement does not depend on external tables return { statement }; } }; diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 63ecf249..95dd3e68 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -144,7 +144,8 @@ namespace sqlpp auto operator()(Statement statement) -> new_statement_t> { - // FIXME need checks here, e.g. if there is recursion + // FIXME need checks here + // check that no cte refers to any of the ctes to the right return { statement, _data }; } }; @@ -158,6 +159,7 @@ namespace sqlpp static Context& _(const T& t, Context& context) { + // FIXME: If there is a recursive CTE, add a "RECURSIVE" here context << " WITH "; interpret_tuple(t._expressions, ',', context); return context; From 25883fc8ea9b44892f4768c7f5112f3fdcaef9bc Mon Sep 17 00:00:00 2001 From: TyRoXx Date: Wed, 4 Feb 2015 21:34:46 +0100 Subject: [PATCH 076/105] enable -Wconversion and fix a warning --- CMakeLists.txt | 1 + examples/select.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1116b7f..ded9a29d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") endif () +set(CMAKE_CXX_FLAGS "-Wconversion ${CMAKE_CXX_FLAGS}") set(include_dir "${PROJECT_SOURCE_DIR}/include") file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h") diff --git a/examples/select.cpp b/examples/select.cpp index 8b4317c2..9c3a767f 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -110,7 +110,7 @@ int main() .from(p.join(x).on(p.feature == x.cheesecake)) .where(true))) { - int id = row.id; + int64_t id = row.id; std::string name = row.name; std::string x_name = row.x.name; int cheesecake = row.x.cheesecake; From 3cef1a12179b84e35811c4d854cb32a14cdf3d84 Mon Sep 17 00:00:00 2001 From: TyRoXx Date: Wed, 4 Feb 2015 21:43:10 +0100 Subject: [PATCH 077/105] enable -Wpedantic and fix all the warnings Conflicts: examples/select.cpp include/sqlpp11/interpret_tuple.h include/sqlpp11/type_traits.h --- CMakeLists.txt | 2 +- examples/select.cpp | 2 +- include/sqlpp11/alias_provider.h | 54 +++++++------- include/sqlpp11/detail/pick_arg.h | 6 +- include/sqlpp11/interpret_tuple.h | 4 +- include/sqlpp11/transaction.h | 2 +- include/sqlpp11/type_traits.h | 119 +++++++++++++++--------------- include/sqlpp11/with.h | 2 +- tests/FunctionTest.cpp | 2 +- tests/MockDb.h | 2 +- tests/SelectTypeTest.cpp | 8 +- 11 files changed, 103 insertions(+), 100 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ded9a29d..69ca76f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") endif () -set(CMAKE_CXX_FLAGS "-Wconversion ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "-Wconversion -Wpedantic ${CMAKE_CXX_FLAGS}") set(include_dir "${PROJECT_SOURCE_DIR}/include") file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h") diff --git a/examples/select.cpp b/examples/select.cpp index 9c3a767f..790fd96b 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -37,7 +37,7 @@ static constexpr bool some_condition = true; static constexpr bool some_other_condition = false; -SQLPP_ALIAS_PROVIDER(cheesecake); +SQLPP_ALIAS_PROVIDER(cheesecake) MockDb db; diff --git a/include/sqlpp11/alias_provider.h b/include/sqlpp11/alias_provider.h index ba07cf9f..57d501ca 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -64,33 +64,33 @@ namespace sqlpp inline namespace alias { - SQLPP_ALIAS_PROVIDER(a); - SQLPP_ALIAS_PROVIDER(b); - SQLPP_ALIAS_PROVIDER(c); - SQLPP_ALIAS_PROVIDER(d); - SQLPP_ALIAS_PROVIDER(e); - SQLPP_ALIAS_PROVIDER(f); - SQLPP_ALIAS_PROVIDER(g); - SQLPP_ALIAS_PROVIDER(h); - SQLPP_ALIAS_PROVIDER(i); - SQLPP_ALIAS_PROVIDER(j); - SQLPP_ALIAS_PROVIDER(k); - SQLPP_ALIAS_PROVIDER(l); - SQLPP_ALIAS_PROVIDER(m); - SQLPP_ALIAS_PROVIDER(n); - SQLPP_ALIAS_PROVIDER(o); - SQLPP_ALIAS_PROVIDER(p); - SQLPP_ALIAS_PROVIDER(q); - SQLPP_ALIAS_PROVIDER(s); - SQLPP_ALIAS_PROVIDER(t); - SQLPP_ALIAS_PROVIDER(u); - SQLPP_ALIAS_PROVIDER(v); - SQLPP_ALIAS_PROVIDER(w); - SQLPP_ALIAS_PROVIDER(x); - SQLPP_ALIAS_PROVIDER(y); - SQLPP_ALIAS_PROVIDER(z); - SQLPP_ALIAS_PROVIDER(left); - SQLPP_ALIAS_PROVIDER(right); + SQLPP_ALIAS_PROVIDER(a) + SQLPP_ALIAS_PROVIDER(b) + SQLPP_ALIAS_PROVIDER(c) + SQLPP_ALIAS_PROVIDER(d) + SQLPP_ALIAS_PROVIDER(e) + SQLPP_ALIAS_PROVIDER(f) + SQLPP_ALIAS_PROVIDER(g) + SQLPP_ALIAS_PROVIDER(h) + SQLPP_ALIAS_PROVIDER(i) + SQLPP_ALIAS_PROVIDER(j) + SQLPP_ALIAS_PROVIDER(k) + SQLPP_ALIAS_PROVIDER(l) + SQLPP_ALIAS_PROVIDER(m) + SQLPP_ALIAS_PROVIDER(n) + SQLPP_ALIAS_PROVIDER(o) + SQLPP_ALIAS_PROVIDER(p) + SQLPP_ALIAS_PROVIDER(q) + SQLPP_ALIAS_PROVIDER(s) + SQLPP_ALIAS_PROVIDER(t) + SQLPP_ALIAS_PROVIDER(u) + SQLPP_ALIAS_PROVIDER(v) + SQLPP_ALIAS_PROVIDER(w) + SQLPP_ALIAS_PROVIDER(x) + SQLPP_ALIAS_PROVIDER(y) + SQLPP_ALIAS_PROVIDER(z) + SQLPP_ALIAS_PROVIDER(left) + SQLPP_ALIAS_PROVIDER(right) } } diff --git a/include/sqlpp11/detail/pick_arg.h b/include/sqlpp11/detail/pick_arg.h index 10cd512b..6c922516 100644 --- a/include/sqlpp11/detail/pick_arg.h +++ b/include/sqlpp11/detail/pick_arg.h @@ -37,20 +37,20 @@ namespace sqlpp typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::true_type&) { return term; - }; + } template typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::false_type&) { return Target::_get_member(statement)._data; - }; + } // Returns a statement's term either by picking the term from the statement or using the new term template typename Target::_data_t pick_arg(Statement statement, Term term) { return pick_arg_impl(statement, term, std::is_same()); - }; + } } } diff --git a/include/sqlpp11/interpret_tuple.h b/include/sqlpp11/interpret_tuple.h index 36c047b7..a51a8288 100644 --- a/include/sqlpp11/interpret_tuple.h +++ b/include/sqlpp11/interpret_tuple.h @@ -54,7 +54,9 @@ namespace sqlpp // See also: "http://stackoverflow.com/questions/6245735/pretty-print-stdtuple/6245777#6245777" // Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could be used using swallow = int[]; - (void) swallow{(interpret_tuple_element(std::get(t), separator, context, useBraces, Is), 0)...}; + (void) swallow{ + 0, //workaround against -Wpedantic GCC warning "zero-size array 'int [0]'" + (interpret_tuple_element(std::get(t), separator, context, useBraces, Is), 0)...}; return context; } diff --git a/include/sqlpp11/transaction.h b/include/sqlpp11/transaction.h index b0d456cc..c140d168 100644 --- a/include/sqlpp11/transaction.h +++ b/include/sqlpp11/transaction.h @@ -90,7 +90,7 @@ namespace sqlpp transaction_t start_transaction(Db& db, bool report_unfinished_transaction = report_auto_rollback) { return { db, report_unfinished_transaction }; - }; + } } #endif diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index e1f0239c..8dee9b18 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -39,7 +39,7 @@ namespace sqlpp { struct can_be_null{}; struct contains_aggregate_function{}; - }; + } namespace detail { @@ -74,7 +74,7 @@ namespace sqlpp namespace tag { struct is_expression{}; - }; + } namespace detail { template @@ -92,7 +92,7 @@ namespace sqlpp namespace tag\ {\ struct name{};\ - };\ + }\ namespace detail\ {\ template\ @@ -103,70 +103,71 @@ namespace sqlpp template\ using name##_t = typename detail::name##_impl::type; - SQLPP_VALUE_TRAIT_GENERATOR(is_value_type); - SQLPP_VALUE_TRAIT_GENERATOR(is_sql_null); - SQLPP_VALUE_TRAIT_GENERATOR(is_boolean); - SQLPP_VALUE_TRAIT_GENERATOR(is_integral); - SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point); + SQLPP_VALUE_TRAIT_GENERATOR(is_value_type) + SQLPP_VALUE_TRAIT_GENERATOR(is_sql_null) + SQLPP_VALUE_TRAIT_GENERATOR(is_boolean) + SQLPP_VALUE_TRAIT_GENERATOR(is_integral) + SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point) template using is_numeric_t = logic::any_t< detail::is_element_of::value, detail::is_element_of::value>; - SQLPP_VALUE_TRAIT_GENERATOR(is_text); - SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value); - SQLPP_VALUE_TRAIT_GENERATOR(is_selectable); - SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression); - SQLPP_VALUE_TRAIT_GENERATOR(is_alias); - SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag); - SQLPP_VALUE_TRAIT_GENERATOR(is_result_field); - SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert); - SQLPP_VALUE_TRAIT_GENERATOR(must_not_update); - SQLPP_VALUE_TRAIT_GENERATOR(require_insert); - SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null); - SQLPP_VALUE_TRAIT_GENERATOR(null_is_trivial_value); + SQLPP_VALUE_TRAIT_GENERATOR(is_text) + SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value) + SQLPP_VALUE_TRAIT_GENERATOR(is_selectable) + SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression) + SQLPP_VALUE_TRAIT_GENERATOR(is_alias) + SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag) + SQLPP_VALUE_TRAIT_GENERATOR(is_result_field) - SQLPP_VALUE_TRAIT_GENERATOR(is_with); - SQLPP_VALUE_TRAIT_GENERATOR(is_cte); - SQLPP_VALUE_TRAIT_GENERATOR(is_statement); - SQLPP_VALUE_TRAIT_GENERATOR(is_prepared_statement); - SQLPP_VALUE_TRAIT_GENERATOR(is_noop); - SQLPP_VALUE_TRAIT_GENERATOR(is_missing); - SQLPP_VALUE_TRAIT_GENERATOR(is_return_value); - SQLPP_VALUE_TRAIT_GENERATOR(is_table); - SQLPP_VALUE_TRAIT_GENERATOR(is_join); - SQLPP_VALUE_TRAIT_GENERATOR(is_pseudo_table); - SQLPP_VALUE_TRAIT_GENERATOR(is_column); - SQLPP_VALUE_TRAIT_GENERATOR(is_select); - SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_select_column_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_from); - SQLPP_VALUE_TRAIT_GENERATOR(is_single_table); - SQLPP_VALUE_TRAIT_GENERATOR(is_into); - SQLPP_VALUE_TRAIT_GENERATOR(is_extra_tables); - SQLPP_VALUE_TRAIT_GENERATOR(is_on); - SQLPP_VALUE_TRAIT_GENERATOR(is_where); - SQLPP_VALUE_TRAIT_GENERATOR(is_group_by); - SQLPP_VALUE_TRAIT_GENERATOR(is_having); - SQLPP_VALUE_TRAIT_GENERATOR(is_order_by); - SQLPP_VALUE_TRAIT_GENERATOR(is_limit); - SQLPP_VALUE_TRAIT_GENERATOR(is_offset); - SQLPP_VALUE_TRAIT_GENERATOR(is_union); - SQLPP_VALUE_TRAIT_GENERATOR(is_using_); - SQLPP_VALUE_TRAIT_GENERATOR(is_column_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_multi_column); - SQLPP_VALUE_TRAIT_GENERATOR(is_value_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_assignment); - SQLPP_VALUE_TRAIT_GENERATOR(is_update_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_insert_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value); - SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_sort_order); - SQLPP_VALUE_TRAIT_GENERATOR(is_parameter); + SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert) + SQLPP_VALUE_TRAIT_GENERATOR(must_not_update) + SQLPP_VALUE_TRAIT_GENERATOR(require_insert) + SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null) + SQLPP_VALUE_TRAIT_GENERATOR(null_is_trivial_value) - SQLPP_VALUE_TRAIT_GENERATOR(requires_braces); + SQLPP_VALUE_TRAIT_GENERATOR(is_statement) + SQLPP_VALUE_TRAIT_GENERATOR(is_prepared_statement) + SQLPP_VALUE_TRAIT_GENERATOR(is_union) + SQLPP_VALUE_TRAIT_GENERATOR(is_with) + SQLPP_VALUE_TRAIT_GENERATOR(is_cte) + SQLPP_VALUE_TRAIT_GENERATOR(is_noop) + SQLPP_VALUE_TRAIT_GENERATOR(is_missing) + SQLPP_VALUE_TRAIT_GENERATOR(is_return_value) + SQLPP_VALUE_TRAIT_GENERATOR(is_table) + SQLPP_VALUE_TRAIT_GENERATOR(is_join) + SQLPP_VALUE_TRAIT_GENERATOR(is_pseudo_table) + SQLPP_VALUE_TRAIT_GENERATOR(is_column) + SQLPP_VALUE_TRAIT_GENERATOR(is_select) + SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_select_column_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_from) + SQLPP_VALUE_TRAIT_GENERATOR(is_single_table) + SQLPP_VALUE_TRAIT_GENERATOR(is_into) + SQLPP_VALUE_TRAIT_GENERATOR(is_extra_tables) + SQLPP_VALUE_TRAIT_GENERATOR(is_on) + SQLPP_VALUE_TRAIT_GENERATOR(is_where) + SQLPP_VALUE_TRAIT_GENERATOR(is_group_by) + SQLPP_VALUE_TRAIT_GENERATOR(is_having) + SQLPP_VALUE_TRAIT_GENERATOR(is_order_by) + SQLPP_VALUE_TRAIT_GENERATOR(is_limit) + SQLPP_VALUE_TRAIT_GENERATOR(is_offset) + SQLPP_VALUE_TRAIT_GENERATOR(is_using_) + SQLPP_VALUE_TRAIT_GENERATOR(is_column_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_multi_column) + SQLPP_VALUE_TRAIT_GENERATOR(is_value_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_assignment) + SQLPP_VALUE_TRAIT_GENERATOR(is_update_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_insert_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value) + SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_sort_order) + SQLPP_VALUE_TRAIT_GENERATOR(is_parameter) - SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment); + SQLPP_VALUE_TRAIT_GENERATOR(requires_braces) + + SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment) template using tag_if = typename std::conditional::type; diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 95dd3e68..48a2e5c3 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -93,7 +93,7 @@ namespace sqlpp return t.with; } -#warning: Need real checks here + // FIXME: Need real checks here using _consistency_check = consistent_t; }; }; diff --git a/tests/FunctionTest.cpp b/tests/FunctionTest.cpp index b0026480..bde10db5 100644 --- a/tests/FunctionTest.cpp +++ b/tests/FunctionTest.cpp @@ -33,7 +33,7 @@ #include MockDb db = {}; -SQLPP_ALIAS_PROVIDER(kaesekuchen); +SQLPP_ALIAS_PROVIDER(kaesekuchen) int main() { diff --git a/tests/MockDb.h b/tests/MockDb.h index 567866d2..9ec072a1 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -103,7 +103,7 @@ struct MockDbT: public sqlpp::connection void next(ResultRow& result_row) { result_row._invalidate(); - }; + } }; // Directly executed statements start here diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index bd0e9be8..70f61811 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -38,10 +38,10 @@ MockDb::_serializer_context_t printer; namespace alias { - SQLPP_ALIAS_PROVIDER(a); - SQLPP_ALIAS_PROVIDER(b); - SQLPP_ALIAS_PROVIDER(left); - SQLPP_ALIAS_PROVIDER(right); + SQLPP_ALIAS_PROVIDER(a) + SQLPP_ALIAS_PROVIDER(b) + SQLPP_ALIAS_PROVIDER(left) + SQLPP_ALIAS_PROVIDER(right) } int main() From b60df812e1a86381f67f0900b4a3b2a93b4abe5c Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 8 Feb 2015 18:26:00 +0100 Subject: [PATCH 078/105] Split union data from union, to be used in ctes, as well --- include/sqlpp11/union.h | 47 +++-------------------- include/sqlpp11/union_data.h | 74 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 42 deletions(-) create mode 100644 include/sqlpp11/union_data.h diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 575f2b08..b45d1930 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -27,6 +27,7 @@ #ifndef SQLPP_UNION_H #define SQLPP_UNION_H +#include #include #include #include @@ -38,7 +39,6 @@ namespace sqlpp { - struct no_union_t; using blank_union_t = statement_t using union_statement_t = typename union_statement_impl::type; - - // UNION DATA - template - struct union_data_t - { - union_data_t(Lhs lhs, Rhs rhs): - _lhs(lhs), - _rhs(rhs) - {} - - union_data_t(const union_data_t&) = default; - union_data_t(union_data_t&&) = default; - union_data_t& operator=(const union_data_t&) = default; - union_data_t& operator=(union_data_t&&) = default; - ~union_data_t() = default; - - Lhs _lhs; - Rhs _rhs; - }; - // UNION(EXPR) template struct union_t @@ -164,7 +144,7 @@ namespace sqlpp using _database_t = typename Policies::_database_t; template - using _check = logic::all_t::value...>; // FIXME and consistent/runnable + using _check = logic::all_t::value...>; template using _new_statement_t = union_statement_t; @@ -192,10 +172,13 @@ namespace sqlpp -> _new_statement_t<_check, union_t, Rhs>> { static_assert(is_statement_t::value, "argument of union call has to be a statement"); + static_assert(has_policy_t::value, "argument of union call has to be a select"); static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); static_assert(std::is_same>, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); + using _result_row_t = get_result_row_t; + static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); return _union_impl(_check, Rhs>{}, rhs); } @@ -216,26 +199,6 @@ namespace sqlpp }; }; - // Interpreters - template - struct serializer_t> - { - using _serialize_check = serialize_check_of; - using T = union_data_t; - - static Context& _(const T& t, Context& context) - { - context << '('; - serialize(t._lhs, context); - context << ") UNION "; - serialize(Flag{}, context); - context << " ("; - serialize(t._rhs, context); - context << ')'; - return context; - } - }; - } #endif diff --git a/include/sqlpp11/union_data.h b/include/sqlpp11/union_data.h new file mode 100644 index 00000000..fd9bba32 --- /dev/null +++ b/include/sqlpp11/union_data.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNION_DATA_H +#define SQLPP_UNION_DATA_H + +#include + +namespace sqlpp +{ + template + struct union_data_t + { + union_data_t(Lhs lhs, Rhs rhs): + _lhs(lhs), + _rhs(rhs) + {} + + union_data_t(const union_data_t&) = default; + union_data_t(union_data_t&&) = default; + union_data_t& operator=(const union_data_t&) = default; + union_data_t& operator=(union_data_t&&) = default; + ~union_data_t() = default; + + Lhs _lhs; + Rhs _rhs; + }; + + // Interpreters + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = union_data_t; + + static Context& _(const T& t, Context& context) + { + context << '('; + serialize(t._lhs, context); + context << ") UNION "; + serialize(Flag{}, context); + context << " ("; + serialize(t._rhs, context); + context << ')'; + return context; + } + }; + +} + +#endif From ee3d803c33d351ddc7bba4609616ab1308510d69 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 8 Feb 2015 18:26:36 +0100 Subject: [PATCH 079/105] Added a few cte checks, fixed logic of requiring and providing ctes --- include/sqlpp11/cte.h | 42 +++++++++++++++++++++++++++++------ include/sqlpp11/type_traits.h | 2 +- include/sqlpp11/with.h | 13 ++++++++++- 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index fd40f789..5fa9c177 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -71,12 +71,12 @@ namespace sqlpp template struct cte_t: public member_t>... { - using _traits = make_traits; + using _traits = make_traits; // FIXME: is table? really? struct _recursive_traits { - using _required_ctes = required_ctes_of; - using _provided_ctes = detail::make_type_set_t; - using _required_tables = required_tables_of; + using _required_ctes = detail::make_joined_set_t, detail::make_type_set_t>; + using _provided_ctes = detail::type_set<>; + using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set; using _provided_outer_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; @@ -122,17 +122,45 @@ namespace sqlpp template struct pre_cte_t { + using _traits = make_traits; // FIXME: is table? really? + struct _recursive_traits + { + using _required_ctes = detail::make_type_set_t; + using _provided_ctes = detail::type_set<>; + using _required_tables = detail::type_set<>; + using _provided_tables = detail::type_set; + using _provided_outer_tables = detail::type_set<>; + using _extra_tables = detail::type_set<>; + using _parameters = std::tuple<>; + using _tags = detail::type_set<>; + }; + + using _alias_t = typename AliasProvider::_alias_t; + template auto as(Statement statement) -> make_cte_t { - // FIXME: Need to check stuff here. - // e.g. make sure that the statement does not require this a cte of this name (other ctes are allowed) - // make sure that the statement does not depend on external tables + static_assert(required_tables_of::size::value == 0, "common table expression must not use unknown tables"); + static_assert(not detail::is_element_of>::value, "common table expression must not self-reference in the first part, use union_all/union_distinct for recursion"); + return { statement }; } }; + template + struct serializer_t> + { + using _serialize_check = consistent_t; + using T = pre_cte_t; + + static Context& _(const T& t, Context& context) + { + context << name_of::char_ptr(); + return context; + } + }; + template auto cte(const AliasProvider&) -> pre_cte_t diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 8dee9b18..d11fa9f7 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -227,7 +227,7 @@ namespace sqlpp struct make_recursive_traits { using _required_ctes = detail::make_joined_set_t...>; - using _provided_ctes = detail::make_joined_set_t...>; + using _provided_ctes = detail::make_joined_set_t...>; using _required_tables = detail::make_joined_set_t...>; using _provided_tables = detail::make_joined_set_t...>; using _provided_outer_tables = detail::make_joined_set_t...>; diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 48a2e5c3..399c94d8 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -62,7 +62,18 @@ namespace sqlpp struct with_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + struct _recursive_traits + { + using _required_ctes = detail::type_set<>; + using _provided_ctes = detail::make_joined_set_t...>; // with provides common table expressions + using _required_tables = detail::type_set<>; + using _provided_tables = detail::type_set<>; + using _provided_outer_tables = detail::type_set<>; + using _extra_tables = detail::type_set<>; + using _parameters = detail::make_parameter_tuple_t...>; + using _tags = detail::type_set<>; + }; + using _is_dynamic = is_database; From c4d77372cf97dc6ff3c3755e982e2b303da8e489 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 8 Feb 2015 19:47:33 +0100 Subject: [PATCH 080/105] The first recursive cte compiles --- include/sqlpp11/cte.h | 66 ++++++++++++++++++++++++++++++++++------- include/sqlpp11/union.h | 5 ++-- tests/WithTest.cpp | 3 ++ 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 5fa9c177..76aa337e 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -27,7 +27,9 @@ #ifndef SQLPP_CTE_H #define SQLPP_CTE_H -#include +#include +#include +#include #include #include #include @@ -38,7 +40,7 @@ namespace sqlpp { - template + template struct cte_t; template @@ -49,7 +51,7 @@ namespace sqlpp using _traits = make_traits, tag::must_not_insert, tag::must_not_update, - tag_if::value> + tag_if::value> >; }; @@ -62,14 +64,14 @@ namespace sqlpp template struct make_cte_impl> { - using type = cte_t...>; + using type = cte_t; }; template using make_cte_t = typename make_cte_impl>::type; - template - struct cte_t: public member_t>... + template + struct cte_t: public member_t, column_t>>... { using _traits = make_traits; // FIXME: is table? really? struct _recursive_traits @@ -83,12 +85,55 @@ namespace sqlpp using _parameters = parameters_of; using _tags = detail::type_set<>; }; - - // FIXME: need a union_distinct and union_all here - // unions can depend on the cte itself In that case the cte is recursive. - using _alias_t = typename AliasProvider::_alias_t; + using _column_tuple_t = std::tuple>...>; + + template + using _check = logic::all_t::value...>; + + template + auto union_distinct(Rhs rhs) const + -> typename std::conditional<_check::value, cte_t, FieldSpecs...>, bad_statement>::type + { + static_assert(is_statement_t::value, "argument of union call has to be a statement"); + static_assert(has_policy_t::value, "argument of union call has to be a select"); + static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); + + using _result_row_t = result_row_t; + static_assert(std::is_same<_result_row_t, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); + + return _union_impl(_check{}, rhs); + } + + template + auto union_all(Rhs rhs) const + -> typename std::conditional<_check::value, cte_t, FieldSpecs...>, bad_statement>::type + { + static_assert(is_statement_t::value, "argument of union call has to be a statement"); + static_assert(has_policy_t::value, "argument of union call has to be a select"); + static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); + + using _result_row_t = result_row_t; + static_assert(std::is_same<_result_row_t, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); + + return _union_impl(_check{}, rhs); + } + + private: + template + auto _union_impl(const std::false_type&, Rhs rhs) const + -> bad_statement; + + template + auto _union_impl(const std::true_type&, Rhs rhs) const + -> cte_t, FieldSpecs...> + { + return union_data_t{_statement, rhs}; + } + + public: + cte_t(Statement statement): _statement(statement){} cte_t(const cte_t&) = default; cte_t(cte_t&&) = default; @@ -143,6 +188,7 @@ namespace sqlpp { static_assert(required_tables_of::size::value == 0, "common table expression must not use unknown tables"); static_assert(not detail::is_element_of>::value, "common table expression must not self-reference in the first part, use union_all/union_distinct for recursion"); + static_assert(is_static_result_row_t>::value, "ctes must not have dynamically added columns"); return { statement }; } diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index b45d1930..066e73e3 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -28,6 +28,7 @@ #define SQLPP_UNION_H #include +#include #include #include #include @@ -159,9 +160,9 @@ namespace sqlpp static_assert(has_policy_t::value, "argument of union call has to be a select"); static_assert(has_result_row_t::value, "argument of a union has to be a complete select statement"); static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a complete select statement or union"); - static_assert(std::is_same>, get_result_row_t>::value, "both arguments in a union have to have the same result columns (type and name)"); using _result_row_t = get_result_row_t; + static_assert(std::is_same>, _result_row_t>::value, "both arguments in a union have to have the same result columns (type and name)"); static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); return _union_impl(_check, Rhs>{}, rhs); @@ -175,9 +176,9 @@ namespace sqlpp static_assert(has_policy_t::value, "argument of union call has to be a select"); static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); - static_assert(std::is_same>, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); using _result_row_t = get_result_row_t; + static_assert(std::is_same>, _result_row_t>::value, "both arguments in a union have to have the same result columns (type and name)"); static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); return _union_impl(_check, Rhs>{}, rhs); diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp index 32b27ed4..f6bd4006 100644 --- a/tests/WithTest.cpp +++ b/tests/WithTest.cpp @@ -40,5 +40,8 @@ int main() db(with(x)(select(x.alpha).from(x).where(true))); + auto y0 = cte(sqlpp::y).as(select(all_of(t)).from(t)); + auto y = y0.union_all(select(all_of(y0)).from(y0).where(false)); + return 0; } From 7e36281e5d3bf19dba9504558787ae52f3ed9abb Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 9 Feb 2015 07:36:53 +0100 Subject: [PATCH 081/105] Fixed a few stray semicolons --- include/sqlpp11/select_column_list.h | 2 +- include/sqlpp11/type_traits.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 727e7513..36e78c91 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -341,7 +341,7 @@ namespace sqlpp auto tuple_merge(Columns... columns) -> decltype(std::tuple_cat(as_tuple::_(columns)...)) { return std::tuple_cat(as_tuple::_(columns)...); - }; + } template using make_select_column_list_t = diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index d11fa9f7..630457a6 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -282,7 +282,7 @@ namespace sqlpp static void _() { static_assert(wrong_t::value, "connection cannot run something that is neither statement nor prepared statement"); - }; + } }; struct assert_prepare_statement_t @@ -293,7 +293,7 @@ namespace sqlpp static void _() { static_assert(wrong_t::value, "connection cannot prepare something that is not a statement"); - }; + } }; template From f50500ba8be36b909062315714db604bfd88ce14 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 9 Feb 2015 18:39:03 +0100 Subject: [PATCH 082/105] Fixed a few superflous semicolons --- include/sqlpp11/group_by.h | 2 +- include/sqlpp11/order_by.h | 2 +- include/sqlpp11/where.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index a8f73185..52c2d53d 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -211,7 +211,7 @@ namespace sqlpp static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in group_by()"); return { static_cast&>(*this), group_by_data_t{expressions...} }; - }; + } }; }; diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index daf50517..32f7a0b8 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -211,7 +211,7 @@ namespace sqlpp static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in order_by()"); return { static_cast&>(*this), order_by_data_t{expressions...} }; - }; + } }; }; diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 161da725..81db3c95 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -190,7 +190,7 @@ namespace sqlpp static void _() { static_assert(wrong_t::value, "where expression required, e.g. where(true)"); - }; + } }; // NO WHERE YET From a5c8b40b077d517cd6c28db3e805cd2aa774c424 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 9 Feb 2015 18:44:25 +0100 Subject: [PATCH 083/105] Adjust WITH clause to serialize RECURSIVE where required --- include/sqlpp11/with.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 399c94d8..fe3d7bda 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -45,6 +45,8 @@ namespace sqlpp template struct with_data_t { + using _is_recursive = logic::any_t; + with_data_t(Expressions... expressions): _expressions(expressions...) {} @@ -74,7 +76,6 @@ namespace sqlpp using _tags = detail::type_set<>; }; - using _is_dynamic = is_database; // Data @@ -172,6 +173,8 @@ namespace sqlpp { // FIXME: If there is a recursive CTE, add a "RECURSIVE" here context << " WITH "; + if (T::_is_recursive::value) + context << "RECURSIVE "; interpret_tuple(t._expressions, ',', context); return context; } From 73097e989f063871eb876a1aa15ede0a6e30860c Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 11 Feb 2015 19:06:16 +0100 Subject: [PATCH 084/105] Mapping ctes to cte_references when used in from, helping with serialization --- include/sqlpp11/cte.h | 52 +++++++++++++++++++++++++---------- include/sqlpp11/from.h | 11 ++++---- include/sqlpp11/table_ref.h | 55 +++++++++++++++++++++++++++++++++++++ include/sqlpp11/with.h | 3 ++ tests/WithTest.cpp | 5 ++++ 5 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 include/sqlpp11/table_ref.h diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 76aa337e..d1c3432f 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -27,6 +27,7 @@ #ifndef SQLPP_CTE_H #define SQLPP_CTE_H +#include #include #include #include @@ -40,9 +41,25 @@ namespace sqlpp { - template + template struct cte_t; + template + struct cte_ref_t; + + template + auto from_table(cte_t t) -> cte_ref_t + { + return cte_ref_t{}; + } + + template + struct from_table_impl> + { + using type = cte_ref_t; + }; + + template struct cte_column_spec_t { @@ -64,13 +81,19 @@ namespace sqlpp template struct make_cte_impl> { - using type = cte_t; + using type = cte_t; }; template using make_cte_t = typename make_cte_impl>::type; - template + template + struct cte_union_is_recursive + { + static constexpr bool value = Lhs or detail::is_element_of>::value; + }; + + template struct cte_t: public member_t, column_t>>... { using _traits = make_traits; // FIXME: is table? really? @@ -86,6 +109,7 @@ namespace sqlpp using _tags = detail::type_set<>; }; using _alias_t = typename AliasProvider::_alias_t; + constexpr static bool _is_recursive = Recursive; using _column_tuple_t = std::tuple>...>; @@ -94,7 +118,7 @@ namespace sqlpp template auto union_distinct(Rhs rhs) const - -> typename std::conditional<_check::value, cte_t, FieldSpecs...>, bad_statement>::type + -> typename std::conditional<_check::value, cte_t::value, union_data_t, FieldSpecs...>, bad_statement>::type { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); @@ -108,7 +132,7 @@ namespace sqlpp template auto union_all(Rhs rhs) const - -> typename std::conditional<_check::value, cte_t, FieldSpecs...>, bad_statement>::type + -> typename std::conditional<_check::value, cte_t::value, union_data_t, FieldSpecs...>, bad_statement>::type { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); @@ -127,7 +151,7 @@ namespace sqlpp template auto _union_impl(const std::true_type&, Rhs rhs) const - -> cte_t, FieldSpecs...> + -> cte_t::value, union_data_t, FieldSpecs...> { return union_data_t{_statement, rhs}; } @@ -144,11 +168,11 @@ namespace sqlpp Statement _statement; }; - template - struct serializer_t> + template + struct serializer_t> { using _serialize_check = serialize_check_of; - using T = cte_t; + using T = cte_t; static Context& _(const T& t, Context& context) { @@ -165,9 +189,9 @@ namespace sqlpp // AliasProviderName AS (ColumnNames) (select/union) // The result row of the select should not have dynamic parts template - struct pre_cte_t + struct cte_ref_t { - using _traits = make_traits; // FIXME: is table? really? + using _traits = make_traits; // FIXME: is table? really? struct _recursive_traits { using _required_ctes = detail::make_type_set_t; @@ -195,10 +219,10 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { using _serialize_check = consistent_t; - using T = pre_cte_t; + using T = cte_ref_t; static Context& _(const T& t, Context& context) { @@ -209,7 +233,7 @@ namespace sqlpp template auto cte(const AliasProvider&) - -> pre_cte_t + -> cte_ref_t { return {}; } diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index bbe7d939..37f5b68a 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -27,6 +27,7 @@ #ifndef SQLPP_FROM_H #define SQLPP_FROM_H +#include #include #include #include @@ -90,7 +91,7 @@ namespace sqlpp template void _add_impl(Table table, const std::true_type&) { - return _data._dynamic_tables.emplace_back(table); + return _data._dynamic_tables.emplace_back(from_table(table)); } template @@ -164,7 +165,7 @@ namespace sqlpp template auto from(Tables... tables) const - -> _new_statement_t<_check, from_t> + -> _new_statement_t<_check, from_t...>> { static_assert(_check::value, "at least one argument is not a table or join in from()"); static_assert(sizeof...(Tables), "at least one table or join argument required in from()"); @@ -173,7 +174,7 @@ namespace sqlpp template auto dynamic_from(Tables... tables) const - -> _new_statement_t<_check, from_t<_database_t, Tables...>> + -> _new_statement_t<_check, from_t<_database_t, from_table_t...>> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_from must not be called in a static statement"); static_assert(_check::value, "at least one argument is not a table or join in from()"); @@ -187,7 +188,7 @@ namespace sqlpp template auto _from_impl(const std::true_type&, Tables... tables) const - -> _new_statement_t> + -> _new_statement_t...>> { static_assert(required_tables_of>::size::value == 0, "at least one table depends on another table in from()"); @@ -197,7 +198,7 @@ namespace sqlpp static_assert(_number_of_tables == _unique_tables::size::value, "at least one duplicate table detected in from()"); static_assert(_number_of_tables == _unique_table_names::size::value, "at least one duplicate table name detected in from()"); - return { static_cast&>(*this), from_data_t{tables...} }; + return { static_cast&>(*this), from_data_t...>{from_table(tables)...} }; } }; diff --git a/include/sqlpp11/table_ref.h b/include/sqlpp11/table_ref.h new file mode 100644 index 00000000..58211093 --- /dev/null +++ b/include/sqlpp11/table_ref.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_TABLE_REF_H +#define SQLPP_TABLE_REF_H + +#include + +namespace sqlpp +{ + template + auto from_table(T t) -> T + { + return t; + } + + template + struct from_table_impl + { + using type = T; + }; + template + using from_table_t = typename from_table_impl::type; + + template + auto table_ref(T t) -> T + { + return t; + } +} + +#endif diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index fe3d7bda..7f696567 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -176,6 +176,7 @@ namespace sqlpp if (T::_is_recursive::value) context << "RECURSIVE "; interpret_tuple(t._expressions, ',', context); + context << ' '; return context; } }; @@ -184,6 +185,8 @@ namespace sqlpp auto with(Expressions... cte) -> blank_with_t { + static_assert(logic::all_t::value...>::value, "at least one expression in with is not a common table expression"); + static_assert(logic::none_t::value...>::value, "at least one expression in with is an incomplete common table expression"); return { {cte...} }; } } diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp index f6bd4006..1ee5cd14 100644 --- a/tests/WithTest.cpp +++ b/tests/WithTest.cpp @@ -43,5 +43,10 @@ int main() auto y0 = cte(sqlpp::y).as(select(all_of(t)).from(t)); auto y = y0.union_all(select(all_of(y0)).from(y0).where(false)); + std::cout << serialize(y, printer).str() << std::endl; printer.reset(); + std::cout << serialize(from_table(y), printer).str() << std::endl; + + db(with(y)(select(y.alpha).from(y).where(true))); + return 0; } From 18b36bf46a3361767186dbcc41d669f29dc062e9 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 12 Feb 2015 18:05:19 +0100 Subject: [PATCH 085/105] recursive ctes seem to be basically working --- include/sqlpp11/cte.h | 101 ++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 29 deletions(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index d1c3432f..f84f3816 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -28,7 +28,6 @@ #define SQLPP_CTE_H #include -#include #include #include #include @@ -41,20 +40,70 @@ namespace sqlpp { - template + template + struct cte_union_t + { + struct _recursive_traits + { + using _required_ctes = detail::make_joined_set_t, required_ctes_of>; + using _provided_ctes = detail::type_set<>; + using _required_tables = detail::type_set<>; + using _provided_tables = detail::type_set<>; + using _provided_outer_tables = detail::type_set<>; + using _extra_tables = detail::type_set<>; + using _parameters = detail::make_parameter_tuple_t, parameters_of>; + using _tags = detail::type_set<>; + }; + + cte_union_t(Lhs lhs, Rhs rhs): + _lhs(lhs), + _rhs(rhs) + {} + + cte_union_t(const cte_union_t&) = default; + cte_union_t(cte_union_t&&) = default; + cte_union_t& operator=(const cte_union_t&) = default; + cte_union_t& operator=(cte_union_t&&) = default; + ~cte_union_t() = default; + + Lhs _lhs; + Rhs _rhs; + }; + + // Interpreters + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = cte_union_t; + + static Context& _(const T& t, Context& context) + { + context << '('; + serialize(t._lhs, context); + context << ") UNION "; + serialize(Flag{}, context); + context << " ("; + serialize(t._rhs, context); + context << ')'; + return context; + } + }; + + template struct cte_t; template struct cte_ref_t; - template - auto from_table(cte_t t) -> cte_ref_t + template + auto from_table(cte_t t) -> cte_ref_t { return cte_ref_t{}; } - template - struct from_table_impl> + template + struct from_table_impl> { using type = cte_ref_t; }; @@ -81,50 +130,45 @@ namespace sqlpp template struct make_cte_impl> { - using type = cte_t; + using type = cte_t; }; template using make_cte_t = typename make_cte_impl>::type; - template - struct cte_union_is_recursive - { - static constexpr bool value = Lhs or detail::is_element_of>::value; - }; - - template + template struct cte_t: public member_t, column_t>>... { using _traits = make_traits; // FIXME: is table? really? struct _recursive_traits { - using _required_ctes = detail::make_joined_set_t, detail::make_type_set_t>; + using _required_ctes = detail::make_joined_set_t, detail::type_set>; using _provided_ctes = detail::type_set<>; using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set; + using _provided_tables = detail::type_set<>; using _provided_outer_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; using _parameters = parameters_of; using _tags = detail::type_set<>; }; using _alias_t = typename AliasProvider::_alias_t; - constexpr static bool _is_recursive = Recursive; + constexpr static bool _is_recursive = detail::is_element_of>::value; using _column_tuple_t = std::tuple>...>; template using _check = logic::all_t::value...>; + using _result_row_t = result_row_t; + template auto union_distinct(Rhs rhs) const - -> typename std::conditional<_check::value, cte_t::value, union_data_t, FieldSpecs...>, bad_statement>::type + -> typename std::conditional<_check::value, cte_t, FieldSpecs...>, bad_statement>::type { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); - using _result_row_t = result_row_t; static_assert(std::is_same<_result_row_t, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); return _union_impl(_check{}, rhs); @@ -132,28 +176,27 @@ namespace sqlpp template auto union_all(Rhs rhs) const - -> typename std::conditional<_check::value, cte_t::value, union_data_t, FieldSpecs...>, bad_statement>::type + -> typename std::conditional<_check::value, cte_t, FieldSpecs...>, bad_statement>::type { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); - using _result_row_t = result_row_t; static_assert(std::is_same<_result_row_t, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); - return _union_impl(_check{}, rhs); + return _union_impl(_check{}, rhs); } private: - template + template auto _union_impl(const std::false_type&, Rhs rhs) const -> bad_statement; - template + template auto _union_impl(const std::true_type&, Rhs rhs) const - -> cte_t::value, union_data_t, FieldSpecs...> + -> cte_t, FieldSpecs...> { - return union_data_t{_statement, rhs}; + return cte_union_t{_statement, rhs}; } public: @@ -168,11 +211,11 @@ namespace sqlpp Statement _statement; }; - template - struct serializer_t> + template + struct serializer_t> { using _serialize_check = serialize_check_of; - using T = cte_t; + using T = cte_t; static Context& _(const T& t, Context& context) { From 2c463b2b515a60536aa9d80b015d5ebaf1e339e1 Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 13 Feb 2015 16:26:45 +0100 Subject: [PATCH 086/105] Added missing includes --- include/sqlpp11/with.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 7f696567..71f8e3a1 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -27,6 +27,8 @@ #ifndef SQLPP_WITH_H #define SQLPP_WITH_H +#include +#include #include #include #include From a09c79b234df5b479016df0207eebac33554e820 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 15 Feb 2015 13:10:39 +0100 Subject: [PATCH 087/105] Removed a few stray semicolons --- include/sqlpp11/insert_value_list.h | 2 +- include/sqlpp11/update_list.h | 2 +- include/sqlpp11/using.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index a0763799..1cc86f62 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -315,7 +315,7 @@ namespace sqlpp static void _() { static_assert(wrong_t::value, "insert values required, e.g. set(...) or default_values()"); - }; + } }; // NO INSERT COLUMNS/VALUES YET diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index ba5ddc8d..5b0d5bf2 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -147,7 +147,7 @@ namespace sqlpp static void _() { static_assert(wrong_t::value, "update assignments required, i.e. set(...)"); - }; + } }; struct no_update_list_t diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index cf1bdea8..f1d9537d 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -192,7 +192,7 @@ namespace sqlpp static_assert(not detail::has_duplicates::value, "at least one duplicate argument detected in using()"); return { static_cast&>(*this), using_data_t{args...} }; - }; + } }; }; From da0d47a805655b7398d832a72c2031cc13a93e02 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 15 Feb 2015 16:06:14 +0100 Subject: [PATCH 088/105] Fixed conditions for using sub select as alias --- include/sqlpp11/select_column_list.h | 2 +- include/sqlpp11/statement.h | 4 ++-- include/sqlpp11/type_traits.h | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 36e78c91..7fae3d2e 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -286,7 +286,7 @@ namespace sqlpp template _alias_t as(const AliasProvider& aliasProvider) const { - run_check_t<_statement_t>::_(); + consistency_check_t<_statement_t>::_(); static_assert(_statement_t::_can_be_used_as_table(), "statement cannot be used as table, e.g. due to missing tables"); static_assert(logic::none_t::value...>::value, "cannot use multi-columns in sub selects"); return _table_t(_get_statement()).as(aliasProvider); diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 8fe803d7..209a62e0 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -130,12 +130,12 @@ namespace sqlpp // A select can be used as a pseudo table if // - at least one column is selected - // - the select is complete (leaks no tables) + // - the select is complete (leaks no table requirements) static constexpr bool _can_be_used_as_table() { return has_result_row_t<_statement_t>::value and _required_tables::size::value == 0 - and _required_ctes::size::value == 0 + and _all_provided_ctes::size::value == 0 // a sub-select must not contain a WITH ? true : false; } diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 630457a6..e6dc033f 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -296,6 +296,21 @@ namespace sqlpp } }; + template + struct consistency_check + { + using type = assert_run_statement_or_prepared_t; + }; + + template + struct consistency_check::value or is_prepared_statement_t::value>::type> + { + using type = typename T::_consistency_check; + }; + + template + using consistency_check_t = typename consistency_check::type; + template struct run_check { From 9e1ecaf15a3702ed45b08bef0af87e1bb33a10a3 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 15 Feb 2015 16:41:08 +0100 Subject: [PATCH 089/105] Fixed weird compiler crash with gcc-4.8.2 I have no idea why this is helping, but it does. I need to invest some time to simplify the templates so that compilers aren't as stressed with it. --- include/sqlpp11/statement.h | 13 +++++++++---- tests/CMakeLists.txt | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 209a62e0..bb636f8f 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -189,12 +189,17 @@ namespace sqlpp using _consistency_check = detail::get_first_if::_consistency_check..., typename _policies_t::_table_check>; - using _prepare_check = detail::get_first_if; + using _run_check = detail::get_first_if; + typename _policies_t::_cte_check, + typename Policies::template _base_t<_policies_t>::_consistency_check..., + typename _policies_t::_table_check>; + + using _prepare_check = detail::get_first_if::_consistency_check..., + typename _policies_t::_table_check>; using _result_type_provider = typename _policies_t::_result_type_provider; template diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 74505083..537f20b4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,18 +6,18 @@ macro (build_and_run arg) add_test("${arg}" "${arg}") endmacro () -#build_and_run(BooleanExpressionTest) -#build_and_run(CustomQueryTest) -#build_and_run(InterpretTest) -#build_and_run(InsertTest) -#build_and_run(RemoveTest) -#build_and_run(UpdateTest) -#build_and_run(SelectTest) -#build_and_run(SelectTypeTest) -#build_and_run(FunctionTest) -#build_and_run(PreparedTest) -#build_and_run(Minimalistic) -#build_and_run(ResultTest) +build_and_run(BooleanExpressionTest) +build_and_run(CustomQueryTest) +build_and_run(InterpretTest) +build_and_run(InsertTest) +build_and_run(RemoveTest) +build_and_run(UpdateTest) +build_and_run(SelectTest) +build_and_run(SelectTypeTest) +build_and_run(FunctionTest) +build_and_run(PreparedTest) +build_and_run(Minimalistic) +build_and_run(ResultTest) build_and_run(UnionTest) build_and_run(WithTest) From 437607813c7c4b422c2db7eedcdbc4466a5f5399 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 15 Feb 2015 16:54:03 +0100 Subject: [PATCH 090/105] Table aliases must not use braces for tables but for sub selects --- include/sqlpp11/table_alias.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 4985a875..c94557f9 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -74,9 +74,12 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - context << "("; + if (requires_braces_t::value) + context << "("; serialize(t._table, context); - context << ") AS " << name_of::char_ptr(); + if (requires_braces_t::value) + context << ")"; + context << " AS " << name_of::char_ptr(); return context; } }; From 97de6fad7fc245f7e3c160c32f5d2cbb3ea4cfbe Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 15 Feb 2015 19:00:21 +0100 Subject: [PATCH 091/105] Adjusted license dates --- CMakeLists.txt | 2 +- LICENSE | 2 +- connector_api/bind_result.h | 2 +- connector_api/connection.h | 2 +- connector_api/interpreter.h | 2 +- connector_api/prepared_statement.h | 2 +- examples/TabSample.h | 2 +- examples/insert.cpp | 2 +- examples/remove.cpp | 2 +- examples/sample.cpp | 2 +- examples/select.cpp | 2 +- examples/update.cpp | 2 +- include/sqlpp11/alias.h | 2 +- include/sqlpp11/alias_provider.h | 2 +- include/sqlpp11/all_of.h | 2 +- include/sqlpp11/any.h | 2 +- include/sqlpp11/assignment.h | 2 +- include/sqlpp11/avg.h | 2 +- include/sqlpp11/bad_statement.h | 2 +- include/sqlpp11/basic_expression_operators.h | 2 +- include/sqlpp11/boolean.h | 2 +- include/sqlpp11/boolean_expression.h | 2 +- include/sqlpp11/char_sequence.h | 2 +- include/sqlpp11/column.h | 2 +- include/sqlpp11/column_fwd.h | 2 +- include/sqlpp11/column_types.h | 2 +- include/sqlpp11/concat.h | 2 +- include/sqlpp11/connection.h | 2 +- include/sqlpp11/count.h | 2 +- include/sqlpp11/cte.h | 2 +- include/sqlpp11/custom_query.h | 2 +- include/sqlpp11/default_value.h | 2 +- include/sqlpp11/detail/copy_tuple_args.h | 2 +- include/sqlpp11/detail/field_index_sequence.h | 2 +- include/sqlpp11/detail/get_first.h | 2 +- include/sqlpp11/detail/get_last.h | 2 +- include/sqlpp11/detail/index_sequence.h | 2 +- include/sqlpp11/detail/pick_arg.h | 2 +- include/sqlpp11/detail/sum.h | 2 +- include/sqlpp11/detail/type_set.h | 2 +- include/sqlpp11/eval.h | 2 +- include/sqlpp11/exception.h | 2 +- include/sqlpp11/exists.h | 2 +- include/sqlpp11/expression.h | 2 +- include/sqlpp11/expression_fwd.h | 2 +- include/sqlpp11/extra_tables.h | 2 +- include/sqlpp11/field_spec.h | 2 +- include/sqlpp11/floating_point.h | 2 +- include/sqlpp11/from.h | 2 +- include/sqlpp11/functions.h | 2 +- include/sqlpp11/group_by.h | 2 +- include/sqlpp11/having.h | 2 +- include/sqlpp11/hidden.h | 2 +- include/sqlpp11/in.h | 2 +- include/sqlpp11/in_fwd.h | 2 +- include/sqlpp11/insert.h | 2 +- include/sqlpp11/insert_value.h | 2 +- include/sqlpp11/insert_value_list.h | 2 +- include/sqlpp11/integral.h | 2 +- include/sqlpp11/interpret.h | 2 +- include/sqlpp11/interpret_tuple.h | 2 +- include/sqlpp11/interpretable.h | 2 +- include/sqlpp11/interpretable_list.h | 2 +- include/sqlpp11/interpreter.h | 2 +- include/sqlpp11/into.h | 2 +- include/sqlpp11/is_not_null.h | 2 +- include/sqlpp11/is_null.h | 2 +- include/sqlpp11/is_null_fwd.h | 2 +- include/sqlpp11/join.h | 2 +- include/sqlpp11/like.h | 2 +- include/sqlpp11/limit.h | 2 +- include/sqlpp11/logic.h | 2 +- include/sqlpp11/max.h | 2 +- include/sqlpp11/min.h | 2 +- include/sqlpp11/multi_column.h | 2 +- include/sqlpp11/named_interpretable.h | 2 +- include/sqlpp11/no_data.h | 2 +- include/sqlpp11/no_value.h | 2 +- include/sqlpp11/noop.h | 2 +- include/sqlpp11/noop_fwd.h | 2 +- include/sqlpp11/not_in.h | 2 +- include/sqlpp11/null.h | 2 +- include/sqlpp11/offset.h | 2 +- include/sqlpp11/on.h | 2 +- include/sqlpp11/order_by.h | 2 +- include/sqlpp11/parameter.h | 2 +- include/sqlpp11/parameter_list.h | 2 +- include/sqlpp11/policy_update.h | 2 +- include/sqlpp11/prepared_execute.h | 2 +- include/sqlpp11/prepared_insert.h | 2 +- include/sqlpp11/prepared_remove.h | 2 +- include/sqlpp11/prepared_select.h | 2 +- include/sqlpp11/prepared_update.h | 2 +- include/sqlpp11/remove.h | 2 +- include/sqlpp11/result.h | 2 +- include/sqlpp11/result_field.h | 2 +- include/sqlpp11/result_field_methods.h | 2 +- include/sqlpp11/result_row.h | 2 +- include/sqlpp11/result_row_fwd.h | 2 +- include/sqlpp11/rhs_wrap.h | 2 +- include/sqlpp11/select.h | 2 +- include/sqlpp11/select_column_list.h | 2 +- include/sqlpp11/select_flag_list.h | 2 +- include/sqlpp11/select_flags.h | 2 +- include/sqlpp11/select_pseudo_table.h | 2 +- include/sqlpp11/serialize.h | 2 +- include/sqlpp11/serializer.h | 2 +- include/sqlpp11/serializer_context.h | 2 +- include/sqlpp11/simple_column.h | 2 +- include/sqlpp11/single_table.h | 2 +- include/sqlpp11/some.h | 2 +- include/sqlpp11/sort_order.h | 2 +- include/sqlpp11/sqlpp11.h | 2 +- include/sqlpp11/statement.h | 2 +- include/sqlpp11/statement_fwd.h | 2 +- include/sqlpp11/sum.h | 2 +- include/sqlpp11/table.h | 2 +- include/sqlpp11/table_alias.h | 2 +- include/sqlpp11/table_ref.h | 2 +- include/sqlpp11/text.h | 2 +- include/sqlpp11/transaction.h | 2 +- include/sqlpp11/tvin.h | 2 +- include/sqlpp11/type_traits.h | 2 +- include/sqlpp11/union.h | 2 +- include/sqlpp11/union_data.h | 2 +- include/sqlpp11/update.h | 2 +- include/sqlpp11/update_list.h | 2 +- include/sqlpp11/using.h | 2 +- include/sqlpp11/value_or_null.h | 2 +- include/sqlpp11/value_type.h | 2 +- include/sqlpp11/value_type_fwd.h | 2 +- include/sqlpp11/verbatim.h | 2 +- include/sqlpp11/verbatim_table.h | 2 +- include/sqlpp11/where.h | 2 +- include/sqlpp11/with.h | 2 +- include/sqlpp11/wrap_operand.h | 2 +- include/sqlpp11/wrap_operand_fwd.h | 2 +- include/sqlpp11/wrong.h | 2 +- scripts/ddl2cpp | 2 +- test_constraints/count_of_count.cpp | 2 +- test_constraints/max_of_max.cpp | 2 +- test_constraints/must_not_insert.cpp | 2 +- test_constraints/must_not_update.cpp | 2 +- test_constraints/no_conversion_operator_if_null_not_trivial.cpp | 2 +- test_constraints/require_insert.cpp | 2 +- tests/BooleanExpressionTest.cpp | 2 +- tests/CustomQueryTest.cpp | 2 +- tests/FunctionTest.cpp | 2 +- tests/InsertTest.cpp | 2 +- tests/InterpretTest.cpp | 2 +- tests/MockDb.h | 2 +- tests/PreparedTest.cpp | 2 +- tests/RemoveTest.cpp | 2 +- tests/ResultTest.cpp | 2 +- tests/SelectTest.cpp | 2 +- tests/SelectTypeTest.cpp | 2 +- tests/UnionTest.cpp | 2 +- tests/UpdateTest.cpp | 2 +- tests/WithTest.cpp | 2 +- tests/is_regular.h | 2 +- tests/sample.sql | 2 +- 161 files changed, 161 insertions(+), 161 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69ca76f5..e44621d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2014, Roland Bock +# Copyright (c) 2013-2015, Roland Bock # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, diff --git a/LICENSE b/LICENSE index 32872e75..6e8b716d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013-2014, Roland Bock +Copyright (c) 2013-2015, Roland Bock All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/connector_api/bind_result.h b/connector_api/bind_result.h index c3b4e233..d14de772 100644 --- a/connector_api/bind_result.h +++ b/connector_api/bind_result.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/connector_api/connection.h b/connector_api/connection.h index e3b7a4dc..9a23d8b7 100644 --- a/connector_api/connection.h +++ b/connector_api/connection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/connector_api/interpreter.h b/connector_api/interpreter.h index 90295276..d59add96 100644 --- a/connector_api/interpreter.h +++ b/connector_api/interpreter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/connector_api/prepared_statement.h b/connector_api/prepared_statement.h index bcd67293..1524e0f0 100644 --- a/connector_api/prepared_statement.h +++ b/connector_api/prepared_statement.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/examples/TabSample.h b/examples/TabSample.h index 377f9c2f..09e7f1ea 100644 --- a/examples/TabSample.h +++ b/examples/TabSample.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/examples/insert.cpp b/examples/insert.cpp index 5c79d5f9..40d2bdf4 100644 --- a/examples/insert.cpp +++ b/examples/insert.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Roland Bock + * Copyright (c) 2014-2015 Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/examples/remove.cpp b/examples/remove.cpp index 49b93799..e078a1d6 100644 --- a/examples/remove.cpp +++ b/examples/remove.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Roland Bock + * Copyright (c) 2014-2015 Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/examples/sample.cpp b/examples/sample.cpp index 5328df05..f5144fd0 100644 --- a/examples/sample.cpp +++ b/examples/sample.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Roland Bock + * Copyright (c) 2014-2015 Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/examples/select.cpp b/examples/select.cpp index 790fd96b..53a2f33f 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Roland Bock + * Copyright (c) 2014-2015 Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/examples/update.cpp b/examples/update.cpp index 82ffa37e..59580681 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Roland Bock + * Copyright (c) 2014-2015 Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/alias.h b/include/sqlpp11/alias.h index 0f792085..5f565ea1 100644 --- a/include/sqlpp11/alias.h +++ b/include/sqlpp11/alias.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/alias_provider.h b/include/sqlpp11/alias_provider.h index 57d501ca..ada9ea1d 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/all_of.h b/include/sqlpp11/all_of.h index 24c8b5b6..55e2c206 100644 --- a/include/sqlpp11/all_of.h +++ b/include/sqlpp11/all_of.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index 2941718f..a180835f 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/assignment.h b/include/sqlpp11/assignment.h index 09c46d64..2677bd00 100644 --- a/include/sqlpp11/assignment.h +++ b/include/sqlpp11/assignment.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/avg.h b/include/sqlpp11/avg.h index 8f313185..d7827abd 100644 --- a/include/sqlpp11/avg.h +++ b/include/sqlpp11/avg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/bad_statement.h b/include/sqlpp11/bad_statement.h index 16b3f7e4..c4094591 100644 --- a/include/sqlpp11/bad_statement.h +++ b/include/sqlpp11/bad_statement.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/basic_expression_operators.h b/include/sqlpp11/basic_expression_operators.h index 3733ca59..3bfeafe1 100644 --- a/include/sqlpp11/basic_expression_operators.h +++ b/include/sqlpp11/basic_expression_operators.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index d324d665..180fd96e 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/boolean_expression.h b/include/sqlpp11/boolean_expression.h index e9ba83a1..f60a610b 100644 --- a/include/sqlpp11/boolean_expression.h +++ b/include/sqlpp11/boolean_expression.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/char_sequence.h b/include/sqlpp11/char_sequence.h index ba05d749..c465ccae 100644 --- a/include/sqlpp11/char_sequence.h +++ b/include/sqlpp11/char_sequence.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 83468e5b..08d1a0f7 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/column_fwd.h b/include/sqlpp11/column_fwd.h index 634bbe0b..c6899454 100644 --- a/include/sqlpp11/column_fwd.h +++ b/include/sqlpp11/column_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/column_types.h b/include/sqlpp11/column_types.h index 79f43f8b..66d0faac 100644 --- a/include/sqlpp11/column_types.h +++ b/include/sqlpp11/column_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/concat.h b/include/sqlpp11/concat.h index 1ceb8d7e..57f113dd 100644 --- a/include/sqlpp11/concat.h +++ b/include/sqlpp11/concat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/connection.h b/include/sqlpp11/connection.h index 7f51fd41..49b178bd 100644 --- a/include/sqlpp11/connection.h +++ b/include/sqlpp11/connection.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index 1403aa8b..ceff0393 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index f84f3816..c37f26d9 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 3a7aaf62..ce332688 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/default_value.h b/include/sqlpp11/default_value.h index a1633305..ede6bb87 100644 --- a/include/sqlpp11/default_value.h +++ b/include/sqlpp11/default_value.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/copy_tuple_args.h b/include/sqlpp11/detail/copy_tuple_args.h index fafabe7b..4f6d483a 100644 --- a/include/sqlpp11/detail/copy_tuple_args.h +++ b/include/sqlpp11/detail/copy_tuple_args.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/field_index_sequence.h b/include/sqlpp11/detail/field_index_sequence.h index 22e82318..e56c74bb 100644 --- a/include/sqlpp11/detail/field_index_sequence.h +++ b/include/sqlpp11/detail/field_index_sequence.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/get_first.h b/include/sqlpp11/detail/get_first.h index 25a784d8..7d7a4d7d 100644 --- a/include/sqlpp11/detail/get_first.h +++ b/include/sqlpp11/detail/get_first.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/get_last.h b/include/sqlpp11/detail/get_last.h index 02bacd4b..0783c2d1 100644 --- a/include/sqlpp11/detail/get_last.h +++ b/include/sqlpp11/detail/get_last.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/index_sequence.h b/include/sqlpp11/detail/index_sequence.h index c45a992f..df9edcea 100644 --- a/include/sqlpp11/detail/index_sequence.h +++ b/include/sqlpp11/detail/index_sequence.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/pick_arg.h b/include/sqlpp11/detail/pick_arg.h index 6c922516..12a7a9c6 100644 --- a/include/sqlpp11/detail/pick_arg.h +++ b/include/sqlpp11/detail/pick_arg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/sum.h b/include/sqlpp11/detail/sum.h index 9296b498..6ebce4ed 100644 --- a/include/sqlpp11/detail/sum.h +++ b/include/sqlpp11/detail/sum.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h index 5e1be6c0..cad901b8 100644 --- a/include/sqlpp11/detail/type_set.h +++ b/include/sqlpp11/detail/type_set.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/eval.h b/include/sqlpp11/eval.h index 3545dd1f..e425376a 100644 --- a/include/sqlpp11/eval.h +++ b/include/sqlpp11/eval.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/exception.h b/include/sqlpp11/exception.h index 8b2fc6a2..dc96e9b2 100644 --- a/include/sqlpp11/exception.h +++ b/include/sqlpp11/exception.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/exists.h b/include/sqlpp11/exists.h index 71b10da0..ad1df80f 100644 --- a/include/sqlpp11/exists.h +++ b/include/sqlpp11/exists.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/expression.h b/include/sqlpp11/expression.h index c2fc6990..366dfa67 100644 --- a/include/sqlpp11/expression.h +++ b/include/sqlpp11/expression.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/expression_fwd.h b/include/sqlpp11/expression_fwd.h index 5e5396a5..6562ee53 100644 --- a/include/sqlpp11/expression_fwd.h +++ b/include/sqlpp11/expression_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index cd4e1068..29300762 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/field_spec.h b/include/sqlpp11/field_spec.h index 16540042..d7359e8b 100644 --- a/include/sqlpp11/field_spec.h +++ b/include/sqlpp11/field_spec.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index ac0915a0..2408d946 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 37f5b68a..40432139 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 409adbfb..a1a611f4 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 52c2d53d..56d99785 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index c26cfa6f..90570f84 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/hidden.h b/include/sqlpp11/hidden.h index 3ceb4f53..313ae6b8 100644 --- a/include/sqlpp11/hidden.h +++ b/include/sqlpp11/hidden.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index da39c909..ae779085 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/in_fwd.h b/include/sqlpp11/in_fwd.h index f35552ef..becbfbbe 100644 --- a/include/sqlpp11/in_fwd.h +++ b/include/sqlpp11/in_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 5aa99a33..e639be61 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/insert_value.h b/include/sqlpp11/insert_value.h index ba7ce56a..8a93d795 100644 --- a/include/sqlpp11/insert_value.h +++ b/include/sqlpp11/insert_value.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 1cc86f62..49e5373d 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index e5123f45..e3a426df 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/interpret.h b/include/sqlpp11/interpret.h index 4d1b2c20..ed12051f 100644 --- a/include/sqlpp11/interpret.h +++ b/include/sqlpp11/interpret.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/interpret_tuple.h b/include/sqlpp11/interpret_tuple.h index a51a8288..bc022f34 100644 --- a/include/sqlpp11/interpret_tuple.h +++ b/include/sqlpp11/interpret_tuple.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/interpretable.h b/include/sqlpp11/interpretable.h index c5104d83..393ca855 100644 --- a/include/sqlpp11/interpretable.h +++ b/include/sqlpp11/interpretable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/interpretable_list.h b/include/sqlpp11/interpretable_list.h index 59457bd5..8a5d1ea2 100644 --- a/include/sqlpp11/interpretable_list.h +++ b/include/sqlpp11/interpretable_list.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/interpreter.h b/include/sqlpp11/interpreter.h index 17ea9ffa..2560bd17 100644 --- a/include/sqlpp11/interpreter.h +++ b/include/sqlpp11/interpreter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index 78413be7..db307dbc 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/is_not_null.h b/include/sqlpp11/is_not_null.h index 0248ce5f..f6467b18 100644 --- a/include/sqlpp11/is_not_null.h +++ b/include/sqlpp11/is_not_null.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/is_null.h b/include/sqlpp11/is_null.h index f45f35c6..8bdc0196 100644 --- a/include/sqlpp11/is_null.h +++ b/include/sqlpp11/is_null.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/is_null_fwd.h b/include/sqlpp11/is_null_fwd.h index 21db3436..155f3922 100644 --- a/include/sqlpp11/is_null_fwd.h +++ b/include/sqlpp11/is_null_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index e4dcb97f..160d1472 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index 97d41e4a..95d1e2b0 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 6d3760d7..4b5dc564 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/logic.h b/include/sqlpp11/logic.h index a70d4110..1db03db4 100644 --- a/include/sqlpp11/logic.h +++ b/include/sqlpp11/logic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/max.h b/include/sqlpp11/max.h index 4bba58fc..cfa43036 100644 --- a/include/sqlpp11/max.h +++ b/include/sqlpp11/max.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/min.h b/include/sqlpp11/min.h index 2077ae4c..e6d97348 100644 --- a/include/sqlpp11/min.h +++ b/include/sqlpp11/min.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index 70dbec66..c5c169b1 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/named_interpretable.h b/include/sqlpp11/named_interpretable.h index 47879ec8..079b19bf 100644 --- a/include/sqlpp11/named_interpretable.h +++ b/include/sqlpp11/named_interpretable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/no_data.h b/include/sqlpp11/no_data.h index 2c0952b4..f90f4377 100644 --- a/include/sqlpp11/no_data.h +++ b/include/sqlpp11/no_data.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/no_value.h b/include/sqlpp11/no_value.h index be1877d1..bf31ad5a 100644 --- a/include/sqlpp11/no_value.h +++ b/include/sqlpp11/no_value.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index dfa2c2ff..eb4315fb 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/noop_fwd.h b/include/sqlpp11/noop_fwd.h index 0c87c75e..a07caba2 100644 --- a/include/sqlpp11/noop_fwd.h +++ b/include/sqlpp11/noop_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/not_in.h b/include/sqlpp11/not_in.h index a8eda8e2..a3b212de 100644 --- a/include/sqlpp11/not_in.h +++ b/include/sqlpp11/not_in.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/null.h b/include/sqlpp11/null.h index 0432c387..167da605 100644 --- a/include/sqlpp11/null.h +++ b/include/sqlpp11/null.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index a43f57bc..d78d77b1 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index 4a23595d..785e0a4f 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index 32f7a0b8..467930e5 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index 542a5cb1..813f0b91 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/parameter_list.h b/include/sqlpp11/parameter_list.h index c4aeba51..b185bf73 100644 --- a/include/sqlpp11/parameter_list.h +++ b/include/sqlpp11/parameter_list.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/policy_update.h b/include/sqlpp11/policy_update.h index 68e31ccc..3a8f3a56 100644 --- a/include/sqlpp11/policy_update.h +++ b/include/sqlpp11/policy_update.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h index c328bbc1..a82287c8 100644 --- a/include/sqlpp11/prepared_execute.h +++ b/include/sqlpp11/prepared_execute.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/prepared_insert.h b/include/sqlpp11/prepared_insert.h index e81a56c0..da87b5bf 100644 --- a/include/sqlpp11/prepared_insert.h +++ b/include/sqlpp11/prepared_insert.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/prepared_remove.h b/include/sqlpp11/prepared_remove.h index d4a4dfad..1b488106 100644 --- a/include/sqlpp11/prepared_remove.h +++ b/include/sqlpp11/prepared_remove.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/prepared_select.h b/include/sqlpp11/prepared_select.h index 70665558..3ee9eb26 100644 --- a/include/sqlpp11/prepared_select.h +++ b/include/sqlpp11/prepared_select.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/prepared_update.h b/include/sqlpp11/prepared_update.h index 4bd54c85..ee9ff791 100644 --- a/include/sqlpp11/prepared_update.h +++ b/include/sqlpp11/prepared_update.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index e9337e14..bb43da68 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/result.h b/include/sqlpp11/result.h index f24eee85..43cb582b 100644 --- a/include/sqlpp11/result.h +++ b/include/sqlpp11/result.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/result_field.h b/include/sqlpp11/result_field.h index 9dbdb27a..7947543a 100644 --- a/include/sqlpp11/result_field.h +++ b/include/sqlpp11/result_field.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/result_field_methods.h b/include/sqlpp11/result_field_methods.h index 4ab50af9..e3231e05 100644 --- a/include/sqlpp11/result_field_methods.h +++ b/include/sqlpp11/result_field_methods.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 67574354..32c4ad36 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/result_row_fwd.h b/include/sqlpp11/result_row_fwd.h index 8df5b4ed..65d5819b 100644 --- a/include/sqlpp11/result_row_fwd.h +++ b/include/sqlpp11/result_row_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/rhs_wrap.h b/include/sqlpp11/rhs_wrap.h index 610ec634..e9a0bad5 100644 --- a/include/sqlpp11/rhs_wrap.h +++ b/include/sqlpp11/rhs_wrap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 89506245..6fe57fd1 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 7fae3d2e..86e14466 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index d4b9fdef..db66ea6f 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index 580d66ab..5db6a0b6 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index c4dbd3b4..44ef4be7 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/serialize.h b/include/sqlpp11/serialize.h index b9fb2cae..b32fbe77 100644 --- a/include/sqlpp11/serialize.h +++ b/include/sqlpp11/serialize.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/serializer.h b/include/sqlpp11/serializer.h index 78280a6e..61974558 100644 --- a/include/sqlpp11/serializer.h +++ b/include/sqlpp11/serializer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/serializer_context.h b/include/sqlpp11/serializer_context.h index df872b54..3fc975d6 100644 --- a/include/sqlpp11/serializer_context.h +++ b/include/sqlpp11/serializer_context.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/simple_column.h b/include/sqlpp11/simple_column.h index e9cff94f..d90f93be 100644 --- a/include/sqlpp11/simple_column.h +++ b/include/sqlpp11/simple_column.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index fe4efefa..72f05877 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/some.h b/include/sqlpp11/some.h index 04f351fe..6ad8bf40 100644 --- a/include/sqlpp11/some.h +++ b/include/sqlpp11/some.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/sort_order.h b/include/sqlpp11/sort_order.h index a5e64e8d..cd0d6357 100644 --- a/include/sqlpp11/sort_order.h +++ b/include/sqlpp11/sort_order.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/sqlpp11.h b/include/sqlpp11/sqlpp11.h index d4278a2f..5d75783b 100644 --- a/include/sqlpp11/sqlpp11.h +++ b/include/sqlpp11/sqlpp11.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index bb636f8f..d6acbbbf 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/statement_fwd.h b/include/sqlpp11/statement_fwd.h index 90d33379..ca4d368b 100644 --- a/include/sqlpp11/statement_fwd.h +++ b/include/sqlpp11/statement_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/sum.h b/include/sqlpp11/sum.h index 6492d39f..91970f9a 100644 --- a/include/sqlpp11/sum.h +++ b/include/sqlpp11/sum.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index e5e6549c..06724089 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index c94557f9..32324b71 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/table_ref.h b/include/sqlpp11/table_ref.h index 58211093..fa3b0fe4 100644 --- a/include/sqlpp11/table_ref.h +++ b/include/sqlpp11/table_ref.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 9ae0c685..9604a43c 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/transaction.h b/include/sqlpp11/transaction.h index c140d168..ee844373 100644 --- a/include/sqlpp11/transaction.h +++ b/include/sqlpp11/transaction.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/tvin.h b/include/sqlpp11/tvin.h index a9c7ba86..ca2af06b 100644 --- a/include/sqlpp11/tvin.h +++ b/include/sqlpp11/tvin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index e6dc033f..322b655f 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 066e73e3..d0860c54 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/union_data.h b/include/sqlpp11/union_data.h index fd9bba32..55379046 100644 --- a/include/sqlpp11/union_data.h +++ b/include/sqlpp11/union_data.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index b24a81fc..1f3019f9 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 5b0d5bf2..28df9045 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index f1d9537d..16fd6875 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/value_or_null.h b/include/sqlpp11/value_or_null.h index 68ce8c83..9cb2f9b2 100644 --- a/include/sqlpp11/value_or_null.h +++ b/include/sqlpp11/value_or_null.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/value_type.h b/include/sqlpp11/value_type.h index 2fa3bee1..ab7f1e1f 100644 --- a/include/sqlpp11/value_type.h +++ b/include/sqlpp11/value_type.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/value_type_fwd.h b/include/sqlpp11/value_type_fwd.h index 805e5662..30d824d4 100644 --- a/include/sqlpp11/value_type_fwd.h +++ b/include/sqlpp11/value_type_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/verbatim.h b/include/sqlpp11/verbatim.h index 48aa73de..5cae04b4 100644 --- a/include/sqlpp11/verbatim.h +++ b/include/sqlpp11/verbatim.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/verbatim_table.h b/include/sqlpp11/verbatim_table.h index 275061b6..0eb63ce4 100644 --- a/include/sqlpp11/verbatim_table.h +++ b/include/sqlpp11/verbatim_table.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 81db3c95..d37519cb 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 71f8e3a1..10d881bb 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/wrap_operand.h b/include/sqlpp11/wrap_operand.h index 04e0100c..8728197d 100644 --- a/include/sqlpp11/wrap_operand.h +++ b/include/sqlpp11/wrap_operand.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/wrap_operand_fwd.h b/include/sqlpp11/wrap_operand_fwd.h index f7f60def..633df0ac 100644 --- a/include/sqlpp11/wrap_operand_fwd.h +++ b/include/sqlpp11/wrap_operand_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/include/sqlpp11/wrong.h b/include/sqlpp11/wrong.h index 9249673e..cfaf1d32 100644 --- a/include/sqlpp11/wrong.h +++ b/include/sqlpp11/wrong.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index 67d885ee..80e0063b 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -1,7 +1,7 @@ #!/usr/bin/env python ## - # Copyright (c) 2013-2014, Roland Bock + # Copyright (c) 2013-2015, Roland Bock # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, diff --git a/test_constraints/count_of_count.cpp b/test_constraints/count_of_count.cpp index 95f089db..11fdf455 100644 --- a/test_constraints/count_of_count.cpp +++ b/test_constraints/count_of_count.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/test_constraints/max_of_max.cpp b/test_constraints/max_of_max.cpp index 96483e9b..0cf08f56 100644 --- a/test_constraints/max_of_max.cpp +++ b/test_constraints/max_of_max.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/test_constraints/must_not_insert.cpp b/test_constraints/must_not_insert.cpp index be6d4ee1..262eb0ea 100644 --- a/test_constraints/must_not_insert.cpp +++ b/test_constraints/must_not_insert.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/test_constraints/must_not_update.cpp b/test_constraints/must_not_update.cpp index 42f9ac04..8e8a4ef2 100644 --- a/test_constraints/must_not_update.cpp +++ b/test_constraints/must_not_update.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/test_constraints/no_conversion_operator_if_null_not_trivial.cpp b/test_constraints/no_conversion_operator_if_null_not_trivial.cpp index 7b995626..64952b80 100644 --- a/test_constraints/no_conversion_operator_if_null_not_trivial.cpp +++ b/test_constraints/no_conversion_operator_if_null_not_trivial.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/test_constraints/require_insert.cpp b/test_constraints/require_insert.cpp index 6fc641ac..701cb699 100644 --- a/test_constraints/require_insert.cpp +++ b/test_constraints/require_insert.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/BooleanExpressionTest.cpp b/tests/BooleanExpressionTest.cpp index 6f0892b9..4e1d49c9 100644 --- a/tests/BooleanExpressionTest.cpp +++ b/tests/BooleanExpressionTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/CustomQueryTest.cpp b/tests/CustomQueryTest.cpp index 96870380..2d926cc0 100644 --- a/tests/CustomQueryTest.cpp +++ b/tests/CustomQueryTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/FunctionTest.cpp b/tests/FunctionTest.cpp index bde10db5..ba9e166f 100644 --- a/tests/FunctionTest.cpp +++ b/tests/FunctionTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/InsertTest.cpp b/tests/InsertTest.cpp index a8dfe96c..99a2d0c5 100644 --- a/tests/InsertTest.cpp +++ b/tests/InsertTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/InterpretTest.cpp b/tests/InterpretTest.cpp index c3813a24..3aa3487c 100644 --- a/tests/InterpretTest.cpp +++ b/tests/InterpretTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/MockDb.h b/tests/MockDb.h index 9ec072a1..7516dd77 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/PreparedTest.cpp b/tests/PreparedTest.cpp index 27a5832e..87b47311 100644 --- a/tests/PreparedTest.cpp +++ b/tests/PreparedTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/RemoveTest.cpp b/tests/RemoveTest.cpp index 0ea34df1..a89ee285 100644 --- a/tests/RemoveTest.cpp +++ b/tests/RemoveTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/ResultTest.cpp b/tests/ResultTest.cpp index db12cbcf..1763868f 100644 --- a/tests/ResultTest.cpp +++ b/tests/ResultTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index 1ff66977..b804aee1 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index 70f61811..2c599d51 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/UnionTest.cpp b/tests/UnionTest.cpp index ca88841c..c01b4ce0 100644 --- a/tests/UnionTest.cpp +++ b/tests/UnionTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/UpdateTest.cpp b/tests/UpdateTest.cpp index e12224ec..42c54af5 100644 --- a/tests/UpdateTest.cpp +++ b/tests/UpdateTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp index 1ee5cd14..81a172ad 100644 --- a/tests/WithTest.cpp +++ b/tests/WithTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/is_regular.h b/tests/is_regular.h index 190d0838..286be4af 100644 --- a/tests/is_regular.h +++ b/tests/is_regular.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/tests/sample.sql b/tests/sample.sql index d70387e3..cdb10660 100644 --- a/tests/sample.sql +++ b/tests/sample.sql @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014, Roland Bock + * Copyright (c) 2013-2015, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, From 436ef67072acd5d50265b6676dbf55cea24b1ee7 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 17 Feb 2015 07:05:41 +0100 Subject: [PATCH 092/105] Replaced recursive traits with local traits which are evaluated recursively Ok, that sounds weird... Earlier, each node in the SQL tree had a struct containing all recursive traits. This is now gone. It only contains a reference to all sub nodes and its own specific traits. --- include/sqlpp11/alias.h | 2 +- include/sqlpp11/any.h | 2 +- include/sqlpp11/assignment.h | 2 +- include/sqlpp11/avg.h | 2 +- include/sqlpp11/boolean_expression.h | 2 +- include/sqlpp11/column.h | 16 +-- include/sqlpp11/concat.h | 2 +- include/sqlpp11/count.h | 14 +-- include/sqlpp11/cte.h | 43 ++------ include/sqlpp11/custom_query.h | 4 +- include/sqlpp11/default_value.h | 2 +- include/sqlpp11/exists.h | 2 +- include/sqlpp11/expression.h | 10 +- include/sqlpp11/extra_tables.h | 16 +-- include/sqlpp11/field_spec.h | 2 +- include/sqlpp11/from.h | 4 +- include/sqlpp11/functions.h | 2 +- include/sqlpp11/group_by.h | 4 +- include/sqlpp11/having.h | 4 +- include/sqlpp11/in.h | 2 +- include/sqlpp11/insert_value.h | 2 +- include/sqlpp11/insert_value_list.h | 8 +- include/sqlpp11/into.h | 4 +- include/sqlpp11/is_not_null.h | 2 +- include/sqlpp11/is_null.h | 2 +- include/sqlpp11/join.h | 16 +-- include/sqlpp11/like.h | 2 +- include/sqlpp11/limit.h | 6 +- include/sqlpp11/max.h | 2 +- include/sqlpp11/min.h | 2 +- include/sqlpp11/multi_column.h | 4 +- include/sqlpp11/noop.h | 2 +- include/sqlpp11/not_in.h | 2 +- include/sqlpp11/null.h | 2 +- include/sqlpp11/offset.h | 6 +- include/sqlpp11/on.h | 2 +- include/sqlpp11/order_by.h | 4 +- include/sqlpp11/parameter.h | 15 +-- include/sqlpp11/prepared_execute.h | 2 +- include/sqlpp11/prepared_insert.h | 2 +- include/sqlpp11/prepared_remove.h | 2 +- include/sqlpp11/prepared_select.h | 2 +- include/sqlpp11/prepared_update.h | 2 +- include/sqlpp11/result_field_methods.h | 16 +-- include/sqlpp11/result_row.h | 2 +- include/sqlpp11/rhs_wrap.h | 2 +- include/sqlpp11/select_column_list.h | 4 +- include/sqlpp11/select_flag_list.h | 4 +- include/sqlpp11/select_flags.h | 6 +- include/sqlpp11/select_pseudo_table.h | 2 +- include/sqlpp11/simple_column.h | 2 +- include/sqlpp11/single_table.h | 4 +- include/sqlpp11/some.h | 2 +- include/sqlpp11/sort_order.h | 2 +- include/sqlpp11/statement.h | 27 ++--- include/sqlpp11/sum.h | 2 +- include/sqlpp11/table.h | 13 +-- include/sqlpp11/table_alias.h | 14 +-- include/sqlpp11/tvin.h | 4 +- include/sqlpp11/type_traits.h | 142 +++++++++++++------------ include/sqlpp11/union.h | 4 +- include/sqlpp11/update_list.h | 4 +- include/sqlpp11/using.h | 4 +- include/sqlpp11/value_or_null.h | 2 +- include/sqlpp11/verbatim.h | 6 +- include/sqlpp11/verbatim_table.h | 5 +- include/sqlpp11/where.h | 6 +- include/sqlpp11/with.h | 16 +-- include/sqlpp11/wrap_operand.h | 8 +- 69 files changed, 208 insertions(+), 325 deletions(-) diff --git a/include/sqlpp11/alias.h b/include/sqlpp11/alias.h index 5f565ea1..ecebe23b 100644 --- a/include/sqlpp11/alias.h +++ b/include/sqlpp11/alias.h @@ -36,7 +36,7 @@ namespace sqlpp struct expression_alias_t { using _traits = make_traits, tag::is_selectable, tag::is_alias>; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(is_expression_t::value, "invalid argument for an expression alias"); static_assert(not is_alias_t::value, "cannot create an alias of an alias"); diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index a180835f..2c876397 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -37,7 +37,7 @@ namespace sqlpp struct any_t { using _traits = make_traits, tag::is_multi_expression>; - using _recursive_traits = make_recursive_traits; struct _alias_t { diff --git a/include/sqlpp11/assignment.h b/include/sqlpp11/assignment.h index 2677bd00..1496a0e1 100644 --- a/include/sqlpp11/assignment.h +++ b/include/sqlpp11/assignment.h @@ -41,7 +41,7 @@ namespace sqlpp struct assignment_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _lhs_t = Lhs; using _rhs_t = rhs_wrap_t, trivial_value_is_null_t<_lhs_t>::value>; diff --git a/include/sqlpp11/avg.h b/include/sqlpp11/avg.h index d7827abd..d184ccb4 100644 --- a/include/sqlpp11/avg.h +++ b/include/sqlpp11/avg.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(is_noop::value or std::is_same::value, "avg() used with flag other than 'distinct'"); static_assert(is_numeric_t::value, "avg() requires a value expression as argument"); diff --git a/include/sqlpp11/boolean_expression.h b/include/sqlpp11/boolean_expression.h index f60a610b..cc72e846 100644 --- a/include/sqlpp11/boolean_expression.h +++ b/include/sqlpp11/boolean_expression.h @@ -36,7 +36,7 @@ namespace sqlpp struct boolean_expression_t: public expression_operators, boolean> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; template boolean_expression_t(Expr expr): diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 08d1a0f7..495e70c7 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -52,19 +52,9 @@ namespace sqlpp using _tags = detail::make_joined_set_t, typename ColumnSpec::_traits::_tags>; }; - struct _recursive_traits - { - using _required_ctes = detail::type_set<>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set
; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = std::tuple<>; - using _tags = typename std::conditional::value, - detail::type_set, - detail::type_set<>>::type; - }; + using _nodes = std::tuple<>; + using _required_tables = detail::type_set
; + using _can_be_null = column_spec_can_be_null_t; using _spec_t = ColumnSpec; using _table = Table; diff --git a/include/sqlpp11/concat.h b/include/sqlpp11/concat.h index 57f113dd..24ebb046 100644 --- a/include/sqlpp11/concat.h +++ b/include/sqlpp11/concat.h @@ -42,7 +42,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(sizeof...(Args) > 0, "concat requires two arguments at least"); static_assert(logic::all_t::value, is_text_t::value...>::value, "at least one non-text argument detected in concat()"); diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index ceff0393..63c5f4c7 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -39,19 +39,9 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - struct _recursive_traits - { - using _required_ctes = required_ctes_of; - using _provided_ctes = detail::type_set<>; - using _required_tables = required_tables_of; - using _provided_tables = provided_tables_of; - using _provided_outer_tables = provided_outer_tables_of; - using _extra_tables = extra_tables_of; - using _parameters = parameters_of; - using _tags = detail::make_difference_set_t, recursive_tags_of>, - detail::type_set>; - }; + using _nodes = std::tuple; + using _can_be_null = std::false_type; static_assert(is_noop::value or std::is_same::value, "count() used with flag other than 'distinct'"); diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index c37f26d9..64ca2d66 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -43,17 +43,9 @@ namespace sqlpp template struct cte_union_t { - struct _recursive_traits - { - using _required_ctes = detail::make_joined_set_t, required_ctes_of>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = detail::make_parameter_tuple_t, parameters_of>; - using _tags = detail::type_set<>; - }; + using _nodes = std::tuple<>; + using _required_ctes = detail::make_joined_set_t, required_ctes_of>; + using _parameters = detail::make_parameter_tuple_t, parameters_of>; cte_union_t(Lhs lhs, Rhs rhs): _lhs(lhs), @@ -140,17 +132,10 @@ namespace sqlpp struct cte_t: public member_t, column_t>>... { using _traits = make_traits; // FIXME: is table? really? - struct _recursive_traits - { - using _required_ctes = detail::make_joined_set_t, detail::type_set>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = parameters_of; - using _tags = detail::type_set<>; - }; + using _nodes = std::tuple<>; + using _required_ctes = detail::make_joined_set_t, detail::type_set>; + using _parameters = parameters_of; + using _alias_t = typename AliasProvider::_alias_t; constexpr static bool _is_recursive = detail::is_element_of>::value; @@ -235,17 +220,9 @@ namespace sqlpp struct cte_ref_t { using _traits = make_traits; // FIXME: is table? really? - struct _recursive_traits - { - using _required_ctes = detail::make_type_set_t; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = std::tuple<>; - using _tags = detail::type_set<>; - }; + using _nodes = std::tuple<>; + using _required_ctes = detail::make_type_set_t; + using _provided_tables = detail::type_set; using _alias_t = typename AliasProvider::_alias_t; diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index ce332688..e9ecc0a9 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -54,9 +54,9 @@ namespace sqlpp { using _methods_t = typename detail::custom_parts_t::_result_methods_t; using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; - using _parameter_check = typename std::conditional::value == 0, + using _parameter_check = typename std::conditional>::value == 0, consistent_t, assert_no_parameters_t>::type; using _run_check = detail::get_first_if; diff --git a/include/sqlpp11/default_value.h b/include/sqlpp11/default_value.h index ede6bb87..be4ff565 100644 --- a/include/sqlpp11/default_value.h +++ b/include/sqlpp11/default_value.h @@ -34,7 +34,7 @@ namespace sqlpp struct default_value_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; static constexpr bool _is_trivial() { return false; } }; diff --git a/include/sqlpp11/exists.h b/include/sqlpp11/exists.h index ad1df80f..d1699a06 100644 --- a/include/sqlpp11/exists.h +++ b/include/sqlpp11/exists.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; static_assert(is_select_t
; + using _nodes = std::tuple
; using _data_t = into_data_t; @@ -108,7 +108,7 @@ namespace sqlpp struct no_into_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/is_not_null.h b/include/sqlpp11/is_not_null.h index f6467b18..ea34a892 100644 --- a/include/sqlpp11/is_not_null.h +++ b/include/sqlpp11/is_not_null.h @@ -40,7 +40,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; struct _alias_t { diff --git a/include/sqlpp11/is_null.h b/include/sqlpp11/is_null.h index 8bdc0196..fd788374 100644 --- a/include/sqlpp11/is_null.h +++ b/include/sqlpp11/is_null.h @@ -40,7 +40,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; struct _alias_t { diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index 160d1472..46eadd48 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -66,18 +66,8 @@ namespace sqlpp struct join_t { using _traits = make_traits; - struct _recursive_traits - { - using _required_ctes = detail::make_joined_set_t, required_ctes_of>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::make_joined_set_t, required_tables_of>; - using _provided_tables = detail::make_joined_set_t, provided_tables_of>; - using _provided_outer_tables = typename JoinType::template _provided_outer_tables; - using _extra_tables = detail::make_joined_set_t, extra_tables_of>; - using _parameters = detail::make_parameter_tuple_t, parameters_of>; - using _tags = detail::type_set<>; - }; - + using _nodes = std::tuple; + using _can_be_null = std::false_type; static_assert(is_table_t::value, "lhs argument for join() has to be a table or join"); static_assert(is_table_t::value, "rhs argument for join() has to be a table"); @@ -86,7 +76,7 @@ namespace sqlpp static_assert(detail::is_disjunct_from, provided_tables_of>::value, "joined tables must not be identical"); - static_assert(_recursive_traits::_required_tables::size::value == 0, "joined tables must not depend on other tables"); + static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); template using set_on_t = join_t; diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index 95d1e2b0..b8ea9952 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -40,7 +40,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; struct _alias_t { diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 4b5dc564..013ff092 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -55,7 +55,7 @@ namespace sqlpp struct limit_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; // Data using _data_t = limit_data_t; @@ -118,7 +118,7 @@ namespace sqlpp struct dynamic_limit_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = dynamic_limit_data_t; @@ -163,7 +163,7 @@ namespace sqlpp struct no_limit_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/max.h b/include/sqlpp11/max.h index cfa43036..6dfcb593 100644 --- a/include/sqlpp11/max.h +++ b/include/sqlpp11/max.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; struct _alias_t { diff --git a/include/sqlpp11/min.h b/include/sqlpp11/min.h index e6d97348..f19a7e6f 100644 --- a/include/sqlpp11/min.h +++ b/include/sqlpp11/min.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; struct _alias_t { diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index c5c169b1..2e3ab96a 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -42,7 +42,7 @@ namespace sqlpp struct multi_column_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(logic::all_t::value...>::value, "multi_column parameters need to be named expressions"); @@ -73,7 +73,7 @@ namespace sqlpp struct multi_column_alias_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(logic::all_t::value...>::value, "multi_column parameters need to be named expressions"); diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index eb4315fb..8fd7ec86 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -37,7 +37,7 @@ namespace sqlpp struct noop { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; struct _alias_t {}; diff --git a/include/sqlpp11/not_in.h b/include/sqlpp11/not_in.h index a3b212de..fdf4ac44 100644 --- a/include/sqlpp11/not_in.h +++ b/include/sqlpp11/not_in.h @@ -41,7 +41,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(sizeof...(Args) > 0, "not_in() requires at least one argument"); diff --git a/include/sqlpp11/null.h b/include/sqlpp11/null.h index 167da605..2a705bb5 100644 --- a/include/sqlpp11/null.h +++ b/include/sqlpp11/null.h @@ -34,7 +34,7 @@ namespace sqlpp struct null_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; }; template diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index d78d77b1..28e4d565 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -55,7 +55,7 @@ namespace sqlpp struct offset_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(is_integral_t::value, "offset requires an integral value or integral parameter"); @@ -120,7 +120,7 @@ namespace sqlpp struct dynamic_offset_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = dynamic_offset_data_t; @@ -177,7 +177,7 @@ namespace sqlpp struct no_offset_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index 785e0a4f..db959026 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -38,7 +38,7 @@ namespace sqlpp struct on_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _is_dynamic = is_database; diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index 467930e5..bdd2c312 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -71,7 +71,7 @@ namespace sqlpp struct order_by_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _is_dynamic = is_database; @@ -141,7 +141,7 @@ namespace sqlpp struct no_order_by_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index 813f0b91..0acbba76 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -38,17 +38,10 @@ namespace sqlpp public expression_operators, ValueType> { using _traits = make_traits; - struct _recursive_traits - { - using _required_ctes = detail::type_set<>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = std::tuple; - using _tags = detail::type_set; - }; + + using _nodes = std::tuple<>; + using _parameters = std::tuple; + using _can_be_null = std::true_type; using _instance_t = member_t>; diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h index a82287c8..56f935d6 100644 --- a/include/sqlpp11/prepared_execute.h +++ b/include/sqlpp11/prepared_execute.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_execute_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_insert.h b/include/sqlpp11/prepared_insert.h index da87b5bf..a44b2214 100644 --- a/include/sqlpp11/prepared_insert.h +++ b/include/sqlpp11/prepared_insert.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_insert_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_remove.h b/include/sqlpp11/prepared_remove.h index 1b488106..0c67cd61 100644 --- a/include/sqlpp11/prepared_remove.h +++ b/include/sqlpp11/prepared_remove.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_remove_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_select.h b/include/sqlpp11/prepared_select.h index 3ee9eb26..112586f7 100644 --- a/include/sqlpp11/prepared_select.h +++ b/include/sqlpp11/prepared_select.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_select_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _result_row_t = typename Statement::template _result_row_t; using _parameter_list_t = make_parameter_list_t; diff --git a/include/sqlpp11/prepared_update.h b/include/sqlpp11/prepared_update.h index ee9ff791..c9190188 100644 --- a/include/sqlpp11/prepared_update.h +++ b/include/sqlpp11/prepared_update.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_update_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/result_field_methods.h b/include/sqlpp11/result_field_methods.h index e3231e05..2e7ec984 100644 --- a/include/sqlpp11/result_field_methods.h +++ b/include/sqlpp11/result_field_methods.h @@ -81,20 +81,8 @@ namespace sqlpp tag::is_expression, tag_if>; - struct _recursive_traits - { - using _required_ctes = detail::type_set<>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = std::tuple<>; - using _tags = typename std::conditional::value, - detail::type_set, - detail::type_set<>>::type; - }; - + using _nodes = std::tuple<>; + using _can_be_null = column_spec_can_be_null_t<_field_spec_t>; }; } diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 32c4ad36..f814037e 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -185,7 +185,7 @@ namespace sqlpp struct _field_spec_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; struct _alias_t {}; }; diff --git a/include/sqlpp11/rhs_wrap.h b/include/sqlpp11/rhs_wrap.h index e9a0bad5..54c1e114 100644 --- a/include/sqlpp11/rhs_wrap.h +++ b/include/sqlpp11/rhs_wrap.h @@ -118,7 +118,7 @@ namespace sqlpp struct rhs_wrap_t { using _traits = typename Expr::_traits; - using _recursive_traits = typename Expr::_recursive_traits; + using _nodes = std::tuple; rhs_wrap_t(Expr expr): _expr(expr) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index 86e14466..ea38d3a5 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -164,7 +164,7 @@ namespace sqlpp struct select_column_list_t { using _traits = typename detail::select_traits::_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _alias_t = typename detail::select_traits::_alias_t; @@ -353,7 +353,7 @@ namespace sqlpp struct no_select_column_list_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; struct _alias_t {}; diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index db66ea6f..1c3f84bf 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -60,7 +60,7 @@ namespace sqlpp struct select_flag_list_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _is_dynamic = is_database; @@ -128,7 +128,7 @@ namespace sqlpp struct no_select_flag_list_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index 5db6a0b6..65a75fb5 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -38,7 +38,7 @@ namespace sqlpp struct all_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; }; static constexpr all_t all = {}; @@ -57,7 +57,7 @@ namespace sqlpp struct distinct_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; }; static constexpr distinct_t distinct = {}; @@ -76,7 +76,7 @@ namespace sqlpp struct straight_join_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; }; static constexpr straight_join_t straight_join = {}; diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 44ef4be7..5953ad30 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -58,7 +58,7 @@ namespace sqlpp NamedExpr...>, select_column_spec_t...> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; select_pseudo_table_t(Select select): _select(select) diff --git a/include/sqlpp11/simple_column.h b/include/sqlpp11/simple_column.h index d90f93be..26e7062f 100644 --- a/include/sqlpp11/simple_column.h +++ b/include/sqlpp11/simple_column.h @@ -39,7 +39,7 @@ namespace sqlpp _column_t _column; using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; }; template diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index 72f05877..c22c1aa4 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -58,7 +58,7 @@ namespace sqlpp struct single_table_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits
; + using _nodes = std::tuple
; static_assert(is_table_t
::value, "argument has to be a table"); static_assert(required_tables_of
::size::value == 0, "table depends on another table"); @@ -99,7 +99,7 @@ namespace sqlpp struct no_single_table_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/some.h b/include/sqlpp11/some.h index 6ad8bf40..9747ebcb 100644 --- a/include/sqlpp11/some.h +++ b/include/sqlpp11/some.h @@ -37,7 +37,7 @@ namespace sqlpp struct some_t { using _traits = make_traits, tag::is_multi_expression>; - using _recursive_traits = make_recursive_traits; struct _alias_t { diff --git a/include/sqlpp11/sort_order.h b/include/sqlpp11/sort_order.h index cd0d6357..546ff4f1 100644 --- a/include/sqlpp11/sort_order.h +++ b/include/sqlpp11/sort_order.h @@ -42,7 +42,7 @@ namespace sqlpp struct sort_order_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; Expression _expression; }; diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index d6acbbbf..59ef4a8f 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -146,34 +146,23 @@ namespace sqlpp no_value_t // if a required statement part is missing (e.g. columns in a select), then the statement cannot be used as a value >::type; + using _traits = make_traits<_value_type, tag_if::value>>; + + using _nodes = std::tuple<>; using _can_be_null = logic::any_t< can_be_null_t<_result_type_provider>::value, detail::make_intersect_set_t< required_tables_of<_result_type_provider>, _all_provided_outer_tables >::size::value != 0>; - - using _traits = make_traits<_value_type, tag_if::value>>; - - struct _recursive_traits - { - using _required_ctes = statement_policies_t::_required_ctes; - using _provided_ctes = detail::type_set<>; - using _required_tables = statement_policies_t::_required_tables; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = detail::make_parameter_tuple_t...>; - using _tags = typename std::conditional<_can_be_null::value, - detail::type_set, - detail::type_set<>>::type; - }; + using _parameters = detail::make_parameter_tuple_t...>; + // required_tables and _required_ctes are defined above using _cte_check = typename std::conditional<_required_ctes::size::value == 0, consistent_t, assert_no_unknown_ctes_t>::type; using _table_check = typename std::conditional<_required_tables::size::value == 0, consistent_t, assert_no_unknown_tables_t>::type; - using _parameter_check = typename std::conditional::value == 0, + using _parameter_check = typename std::conditional::value == 0, consistent_t, assert_no_parameters_t>::type; }; } @@ -212,7 +201,7 @@ namespace sqlpp tag_if::value>, tag_if::value>::value>, tag::requires_braces>; - using _recursive_traits = typename _policies_t::_recursive_traits; + using _nodes = std::tuple<_policies_t>; using _used_outer_tables = typename _policies_t::_all_provided_outer_tables; using _alias_t = typename _result_type_provider::_alias_t; @@ -286,7 +275,7 @@ namespace sqlpp struct statement_name_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = NameData; diff --git a/include/sqlpp11/sum.h b/include/sqlpp11/sum.h index 91970f9a..e23f6fb9 100644 --- a/include/sqlpp11/sum.h +++ b/include/sqlpp11/sum.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; static_assert(is_noop::value or std::is_same::value, "sum() used with flag other than 'distinct'"); static_assert(is_numeric_t::value, "sum() requires a numeric expression as argument"); diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 06724089..06b2aa93 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -46,17 +46,8 @@ namespace sqlpp { using _traits = make_traits; - struct _recursive_traits - { - using _required_ctes = detail::type_set<>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set
; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = std::tuple<>; - using _tags = detail::type_set<>; - }; + using _nodes = std::tuple<>; + using _provided_tables = detail::type_set
; static_assert(sizeof...(ColumnSpec), "at least one column required per table"); using _required_insert_columns = typename detail::make_type_set_if...>::type; diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 32324b71..44277b71 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -42,17 +42,9 @@ namespace sqlpp //FIXME: Need to add join functionality using _traits = make_traits, tag::is_table, tag::is_alias, tag_if::value>>; - struct _recursive_traits - { - using _required_ctes = required_ctes_of
; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = std::tuple<>; - using _tags = detail::type_set<>; - }; + using _nodes = std::tuple<>; + using _required_ctes = required_ctes_of
; + using _provided_tables = detail::type_set; static_assert(required_tables_of
::size::value == 0, "table aliases must not depend on external tables"); diff --git a/include/sqlpp11/tvin.h b/include/sqlpp11/tvin.h index ca2af06b..c5c1ad7d 100644 --- a/include/sqlpp11/tvin.h +++ b/include/sqlpp11/tvin.h @@ -40,7 +40,7 @@ namespace sqlpp struct tvin_arg_t { using _traits = make_traits, tag::is_expression>; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _operand_t = Operand; @@ -102,7 +102,7 @@ namespace sqlpp struct tvin_t { using _traits = make_traits, tag::is_expression>; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _operand_t = Operand; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 322b655f..2a897c4b 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -38,29 +38,8 @@ namespace sqlpp namespace tag { struct can_be_null{}; - struct contains_aggregate_function{}; } - namespace detail - { - template - struct can_be_null_impl { using type = std::false_type; }; - template - struct can_be_null_impl::value>::type> { using type = std::true_type; }; - } - template - using can_be_null_t = typename detail::can_be_null_impl::type; - - namespace detail - { - template - struct contains_aggregate_function_impl { using type = std::false_type; }; - template - struct contains_aggregate_function_impl::value>::type> { using type = std::true_type; }; - } - template - using contains_aggregate_function_t = typename detail::contains_aggregate_function_impl::type; - namespace detail { template @@ -82,7 +61,7 @@ namespace sqlpp template struct is_expression_impl::value - and not detail::is_element_of::value + //and not detail::is_element_of::value FIXME: Needed here? >::type> { using type = std::true_type; }; } template @@ -186,29 +165,80 @@ namespace sqlpp template using cpp_value_type_of = typename value_type_of::_cpp_value_type; - template - using required_ctes_of = typename T::_recursive_traits::_required_ctes; +#define SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(trait) \ + namespace detail\ + {\ + template\ + struct trait##_of_impl\ + {\ + using type = typename trait##_of_impl::type;\ + };\ + template\ + struct trait##_of_impl::value>::type>\ + {\ + using type = typename T::_##trait;\ + };\ + template\ + struct trait##_of_impl, void>\ + {\ + using type = detail::make_joined_set_t::type...>;\ + };\ + }\ + template\ + using trait##_of = typename detail::trait##_of_impl::type; - template - using provided_ctes_of = typename T::_recursive_traits::_provided_ctes; + SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(required_ctes) + SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(provided_ctes) + SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(required_tables) + SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(provided_tables) + SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(provided_outer_tables) + SQLPP_RECURSIVE_TRAIT_SET_GENERATOR(extra_tables) - template - using required_tables_of = typename T::_recursive_traits::_required_tables; +#define SQLPP_RECURSIVE_TRAIT_GENERATOR(trait) \ + namespace detail\ + {\ + template\ + struct trait##_impl\ + {\ + using type = typename trait##_impl::type;\ + };\ + template\ + struct trait##_impl::value>::type>\ + {\ + using type = typename T::_##trait;\ + };\ + template\ + struct trait##_impl, void>\ + {\ + using type = logic::any_t::type::value...>;\ + };\ + }\ + template\ + using trait##_t = typename detail::trait##_impl::type; - template - using provided_tables_of = typename T::_recursive_traits::_provided_tables; + SQLPP_RECURSIVE_TRAIT_GENERATOR(can_be_null) + SQLPP_RECURSIVE_TRAIT_GENERATOR(contains_aggregate_function) - template - using provided_outer_tables_of = typename T::_recursive_traits::_provided_outer_tables; - - template - using extra_tables_of = typename T::_recursive_traits::_extra_tables; - - template - using parameters_of = typename T::_recursive_traits::_parameters; - - template - using recursive_tags_of = typename T::_recursive_traits::_tags; + namespace detail + { + template + struct parameters_of_impl + { + using type = typename parameters_of_impl::type; + }; + template + struct parameters_of_impl::value>::type> + { + using type = typename T::_parameters; + }; + template + struct parameters_of_impl, void> + { + using type = detail::make_parameter_tuple_t::type...>; + }; + } + template\ + using parameters_of = typename detail::parameters_of_impl::type; template using alias_of = typename T::_alias_t; @@ -223,36 +253,10 @@ namespace sqlpp using _tags = detail::make_type_set_t; }; - template - struct make_recursive_traits - { - using _required_ctes = detail::make_joined_set_t...>; - using _provided_ctes = detail::make_joined_set_t...>; - using _required_tables = detail::make_joined_set_t...>; - using _provided_tables = detail::make_joined_set_t...>; - using _provided_outer_tables = detail::make_joined_set_t...>; - using _extra_tables = detail::make_joined_set_t...>; - using _parameters = detail::make_parameter_tuple_t...>; - using _tags = detail::make_joined_set_t...>; - }; - - template - struct recursive_tags - { - using _required_ctes = detail::type_set<>; - using _provided_ctes = detail::type_set<>; - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = std::tuple<>; - using _tags = detail::type_set; - }; - struct aggregate_function { - struct _traits { using _value_type = void; using _tags = detail::type_set<>; }; - using _recursive_traits = recursive_tags; + using _nodes = std::tuple<>; + using _contains_aggregate_function = std::true_type; }; template diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index d0860c54..22023b32 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -66,7 +66,7 @@ namespace sqlpp struct union_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _alias_t = struct{}; @@ -114,7 +114,7 @@ namespace sqlpp struct no_union_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 28df9045..324a8284 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -68,7 +68,7 @@ namespace sqlpp struct update_list_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _is_dynamic = is_database; // Data @@ -153,7 +153,7 @@ namespace sqlpp struct no_update_list_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index 16fd6875..7f8b78fd 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -58,7 +58,7 @@ namespace sqlpp struct using_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _is_dynamic = is_database; @@ -121,7 +121,7 @@ namespace sqlpp struct no_using_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/value_or_null.h b/include/sqlpp11/value_or_null.h index 9cb2f9b2..8c78c698 100644 --- a/include/sqlpp11/value_or_null.h +++ b/include/sqlpp11/value_or_null.h @@ -51,7 +51,7 @@ namespace sqlpp using _cpp_value_type = typename ValueType::_cpp_value_type; using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; value_or_null_t(_cpp_value_type value): _value(value), diff --git a/include/sqlpp11/verbatim.h b/include/sqlpp11/verbatim.h index 5cae04b4..b65ec3d8 100644 --- a/include/sqlpp11/verbatim.h +++ b/include/sqlpp11/verbatim.h @@ -39,10 +39,8 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - struct _recursive_traits : public make_recursive_traits<> - { - using _tags = detail::type_set; // since we do not know what's going on inside the verbatim, we assume it can be null - }; + using _nodes = std::tuple<>; + using _can_be_null = std::true_type; // since we do not know what's going on inside the verbatim, we assume it can be null verbatim_t(std::string verbatim): _verbatim(verbatim) {} verbatim_t(const verbatim_t&) = default; diff --git a/include/sqlpp11/verbatim_table.h b/include/sqlpp11/verbatim_table.h index 0eb63ce4..2b23e761 100644 --- a/include/sqlpp11/verbatim_table.h +++ b/include/sqlpp11/verbatim_table.h @@ -50,10 +50,7 @@ namespace sqlpp struct verbatim_table_t: public table_t { - struct _recursive_traits: public table_t::_recursive_traits - { - using _provided_outer_tables = detail::type_set; - }; + using _nodes = std::tuple<>; struct _alias_t { diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index d37519cb..a8145c06 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -71,7 +71,7 @@ namespace sqlpp struct where_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits; + using _nodes = std::tuple; using _is_dynamic = is_database; @@ -149,7 +149,7 @@ namespace sqlpp struct where_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = where_data_t; @@ -198,7 +198,7 @@ namespace sqlpp struct no_where_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 10d881bb..e736f561 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -66,17 +66,9 @@ namespace sqlpp struct with_t { using _traits = make_traits; - struct _recursive_traits - { - using _required_ctes = detail::type_set<>; - using _provided_ctes = detail::make_joined_set_t...>; // with provides common table expressions - using _required_tables = detail::type_set<>; - using _provided_tables = detail::type_set<>; - using _provided_outer_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - using _parameters = detail::make_parameter_tuple_t...>; - using _tags = detail::type_set<>; - }; + using _nodes = std::tuple<>; + using _provided_ctes = detail::make_joined_set_t...>; // with provides common table expressions + using _parameters = detail::make_parameter_tuple_t...>; using _is_dynamic = is_database; @@ -116,7 +108,7 @@ namespace sqlpp struct no_with_t { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/wrap_operand.h b/include/sqlpp11/wrap_operand.h index 8728197d..7cbdcb9f 100644 --- a/include/sqlpp11/wrap_operand.h +++ b/include/sqlpp11/wrap_operand.h @@ -43,7 +43,7 @@ namespace sqlpp struct boolean_operand: public alias_operators { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _value_t = bool; @@ -82,7 +82,7 @@ namespace sqlpp struct integral_operand: public alias_operators { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _value_t = int64_t; @@ -122,7 +122,7 @@ namespace sqlpp struct floating_point_operand: public alias_operators { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _value_t = double; @@ -161,7 +161,7 @@ namespace sqlpp struct text_operand: public alias_operators { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + using _nodes = std::tuple<>; using _value_t = std::string; From 1e9910b12f53b6bb6507cd6615c9f3fa7612ad27 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 17 Feb 2015 08:03:19 +0100 Subject: [PATCH 093/105] Replaced node tuple by node type vector --- include/sqlpp11/alias.h | 2 +- include/sqlpp11/any.h | 2 +- include/sqlpp11/assignment.h | 2 +- include/sqlpp11/avg.h | 2 +- include/sqlpp11/boolean_expression.h | 2 +- include/sqlpp11/column.h | 2 +- include/sqlpp11/concat.h | 2 +- include/sqlpp11/count.h | 2 +- include/sqlpp11/cte.h | 6 ++-- include/sqlpp11/custom_query.h | 2 +- include/sqlpp11/default_value.h | 2 +- include/sqlpp11/detail/type_vector.h | 41 ++++++++++++++++++++++++++ include/sqlpp11/exists.h | 2 +- include/sqlpp11/expression.h | 10 +++---- include/sqlpp11/extra_tables.h | 4 +-- include/sqlpp11/field_spec.h | 2 +- include/sqlpp11/from.h | 4 +-- include/sqlpp11/functions.h | 2 +- include/sqlpp11/group_by.h | 4 +-- include/sqlpp11/having.h | 4 +-- include/sqlpp11/in.h | 2 +- include/sqlpp11/insert_value.h | 2 +- include/sqlpp11/insert_value_list.h | 8 ++--- include/sqlpp11/into.h | 4 +-- include/sqlpp11/is_not_null.h | 2 +- include/sqlpp11/is_null.h | 2 +- include/sqlpp11/join.h | 2 +- include/sqlpp11/like.h | 2 +- include/sqlpp11/limit.h | 6 ++-- include/sqlpp11/max.h | 2 +- include/sqlpp11/min.h | 2 +- include/sqlpp11/multi_column.h | 4 +-- include/sqlpp11/noop.h | 2 +- include/sqlpp11/not_in.h | 2 +- include/sqlpp11/null.h | 2 +- include/sqlpp11/offset.h | 6 ++-- include/sqlpp11/on.h | 2 +- include/sqlpp11/order_by.h | 4 +-- include/sqlpp11/parameter.h | 2 +- include/sqlpp11/prepared_execute.h | 2 +- include/sqlpp11/prepared_insert.h | 2 +- include/sqlpp11/prepared_remove.h | 2 +- include/sqlpp11/prepared_select.h | 2 +- include/sqlpp11/prepared_update.h | 2 +- include/sqlpp11/result_field_methods.h | 2 +- include/sqlpp11/result_row.h | 2 +- include/sqlpp11/rhs_wrap.h | 2 +- include/sqlpp11/select_column_list.h | 4 +-- include/sqlpp11/select_flag_list.h | 4 +-- include/sqlpp11/select_flags.h | 6 ++-- include/sqlpp11/select_pseudo_table.h | 2 +- include/sqlpp11/simple_column.h | 2 +- include/sqlpp11/single_table.h | 4 +-- include/sqlpp11/some.h | 2 +- include/sqlpp11/sort_order.h | 2 +- include/sqlpp11/statement.h | 6 ++-- include/sqlpp11/sum.h | 2 +- include/sqlpp11/table.h | 2 +- include/sqlpp11/table_alias.h | 2 +- include/sqlpp11/tvin.h | 4 +-- include/sqlpp11/type_traits.h | 9 +++--- include/sqlpp11/union.h | 4 +-- include/sqlpp11/update_list.h | 4 +-- include/sqlpp11/using.h | 4 +-- include/sqlpp11/value_or_null.h | 2 +- include/sqlpp11/verbatim.h | 2 +- include/sqlpp11/verbatim_table.h | 2 +- include/sqlpp11/where.h | 6 ++-- include/sqlpp11/with.h | 4 +-- include/sqlpp11/wrap_operand.h | 8 ++--- 70 files changed, 151 insertions(+), 109 deletions(-) create mode 100644 include/sqlpp11/detail/type_vector.h diff --git a/include/sqlpp11/alias.h b/include/sqlpp11/alias.h index ecebe23b..013d2e6f 100644 --- a/include/sqlpp11/alias.h +++ b/include/sqlpp11/alias.h @@ -36,7 +36,7 @@ namespace sqlpp struct expression_alias_t { using _traits = make_traits, tag::is_selectable, tag::is_alias>; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(is_expression_t::value, "invalid argument for an expression alias"); static_assert(not is_alias_t::value, "cannot create an alias of an alias"); diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index 2c876397..8585de1d 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -37,7 +37,7 @@ namespace sqlpp struct any_t { using _traits = make_traits, tag::is_multi_expression>; - using _nodes = std::tuple; struct _alias_t { diff --git a/include/sqlpp11/assignment.h b/include/sqlpp11/assignment.h index 1496a0e1..4c405d6b 100644 --- a/include/sqlpp11/assignment.h +++ b/include/sqlpp11/assignment.h @@ -41,7 +41,7 @@ namespace sqlpp struct assignment_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _lhs_t = Lhs; using _rhs_t = rhs_wrap_t, trivial_value_is_null_t<_lhs_t>::value>; diff --git a/include/sqlpp11/avg.h b/include/sqlpp11/avg.h index d184ccb4..d332cf33 100644 --- a/include/sqlpp11/avg.h +++ b/include/sqlpp11/avg.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(is_noop::value or std::is_same::value, "avg() used with flag other than 'distinct'"); static_assert(is_numeric_t::value, "avg() requires a value expression as argument"); diff --git a/include/sqlpp11/boolean_expression.h b/include/sqlpp11/boolean_expression.h index cc72e846..73ee01ff 100644 --- a/include/sqlpp11/boolean_expression.h +++ b/include/sqlpp11/boolean_expression.h @@ -36,7 +36,7 @@ namespace sqlpp struct boolean_expression_t: public expression_operators, boolean> { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; template boolean_expression_t(Expr expr): diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 495e70c7..8a6911bc 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -52,7 +52,7 @@ namespace sqlpp using _tags = detail::make_joined_set_t, typename ColumnSpec::_traits::_tags>; }; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _required_tables = detail::type_set
; using _can_be_null = column_spec_can_be_null_t; diff --git a/include/sqlpp11/concat.h b/include/sqlpp11/concat.h index 24ebb046..bc0ac76b 100644 --- a/include/sqlpp11/concat.h +++ b/include/sqlpp11/concat.h @@ -42,7 +42,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(sizeof...(Args) > 0, "concat requires two arguments at least"); static_assert(logic::all_t::value, is_text_t::value...>::value, "at least one non-text argument detected in concat()"); diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index 63c5f4c7..f2801f98 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -40,7 +40,7 @@ namespace sqlpp { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _can_be_null = std::false_type; static_assert(is_noop::value or std::is_same::value, "count() used with flag other than 'distinct'"); diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 64ca2d66..376b262d 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -43,7 +43,7 @@ namespace sqlpp template struct cte_union_t { - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _required_ctes = detail::make_joined_set_t, required_ctes_of>; using _parameters = detail::make_parameter_tuple_t, parameters_of>; @@ -132,7 +132,7 @@ namespace sqlpp struct cte_t: public member_t, column_t>>... { using _traits = make_traits; // FIXME: is table? really? - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _required_ctes = detail::make_joined_set_t, detail::type_set>; using _parameters = parameters_of; @@ -220,7 +220,7 @@ namespace sqlpp struct cte_ref_t { using _traits = make_traits; // FIXME: is table? really? - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _required_ctes = detail::make_type_set_t; using _provided_tables = detail::type_set; diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index e9ecc0a9..792be16a 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -54,7 +54,7 @@ namespace sqlpp { using _methods_t = typename detail::custom_parts_t::_result_methods_t; using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _parameter_check = typename std::conditional>::value == 0, consistent_t, assert_no_parameters_t>::type; diff --git a/include/sqlpp11/default_value.h b/include/sqlpp11/default_value.h index be4ff565..1a71442a 100644 --- a/include/sqlpp11/default_value.h +++ b/include/sqlpp11/default_value.h @@ -34,7 +34,7 @@ namespace sqlpp struct default_value_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; static constexpr bool _is_trivial() { return false; } }; diff --git a/include/sqlpp11/detail/type_vector.h b/include/sqlpp11/detail/type_vector.h new file mode 100644 index 00000000..06e41d25 --- /dev/null +++ b/include/sqlpp11/detail/type_vector.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_DETAIL_TYPE_VECTOR_H +#define SQLPP_DETAIL_TYPE_VECTOR_H + +namespace sqlpp +{ + namespace detail + { + template + struct type_vector + {}; + } +} + + +#endif diff --git a/include/sqlpp11/exists.h b/include/sqlpp11/exists.h index d1699a06..be72191f 100644 --- a/include/sqlpp11/exists.h +++ b/include/sqlpp11/exists.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = std::tuple; static_assert(is_select_t
; + using _nodes = detail::type_vector
; using _data_t = into_data_t; @@ -108,7 +108,7 @@ namespace sqlpp struct no_into_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/is_not_null.h b/include/sqlpp11/is_not_null.h index ea34a892..78e49123 100644 --- a/include/sqlpp11/is_not_null.h +++ b/include/sqlpp11/is_not_null.h @@ -40,7 +40,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; struct _alias_t { diff --git a/include/sqlpp11/is_null.h b/include/sqlpp11/is_null.h index fd788374..0a798067 100644 --- a/include/sqlpp11/is_null.h +++ b/include/sqlpp11/is_null.h @@ -40,7 +40,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; struct _alias_t { diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index 46eadd48..8e2578d6 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -66,7 +66,7 @@ namespace sqlpp struct join_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _can_be_null = std::false_type; static_assert(is_table_t::value, "lhs argument for join() has to be a table or join"); diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index b8ea9952..02adeba0 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -40,7 +40,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; struct _alias_t { diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 013ff092..c740c8dc 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -55,7 +55,7 @@ namespace sqlpp struct limit_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; // Data using _data_t = limit_data_t; @@ -118,7 +118,7 @@ namespace sqlpp struct dynamic_limit_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = dynamic_limit_data_t; @@ -163,7 +163,7 @@ namespace sqlpp struct no_limit_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/max.h b/include/sqlpp11/max.h index 6dfcb593..c497a56d 100644 --- a/include/sqlpp11/max.h +++ b/include/sqlpp11/max.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _nodes = std::tuple; + using _nodes = detail::type_vector; struct _alias_t { diff --git a/include/sqlpp11/min.h b/include/sqlpp11/min.h index f19a7e6f..95649823 100644 --- a/include/sqlpp11/min.h +++ b/include/sqlpp11/min.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _nodes = std::tuple; + using _nodes = detail::type_vector; struct _alias_t { diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index 2e3ab96a..8147d3c2 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -42,7 +42,7 @@ namespace sqlpp struct multi_column_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(logic::all_t::value...>::value, "multi_column parameters need to be named expressions"); @@ -73,7 +73,7 @@ namespace sqlpp struct multi_column_alias_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(logic::all_t::value...>::value, "multi_column parameters need to be named expressions"); diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index 8fd7ec86..0a023b80 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -37,7 +37,7 @@ namespace sqlpp struct noop { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; struct _alias_t {}; diff --git a/include/sqlpp11/not_in.h b/include/sqlpp11/not_in.h index fdf4ac44..cddfc119 100644 --- a/include/sqlpp11/not_in.h +++ b/include/sqlpp11/not_in.h @@ -41,7 +41,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(sizeof...(Args) > 0, "not_in() requires at least one argument"); diff --git a/include/sqlpp11/null.h b/include/sqlpp11/null.h index 2a705bb5..9b01b69e 100644 --- a/include/sqlpp11/null.h +++ b/include/sqlpp11/null.h @@ -34,7 +34,7 @@ namespace sqlpp struct null_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; }; template diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index 28e4d565..bb9b1406 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -55,7 +55,7 @@ namespace sqlpp struct offset_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(is_integral_t::value, "offset requires an integral value or integral parameter"); @@ -120,7 +120,7 @@ namespace sqlpp struct dynamic_offset_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = dynamic_offset_data_t; @@ -177,7 +177,7 @@ namespace sqlpp struct no_offset_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index db959026..81cff460 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -38,7 +38,7 @@ namespace sqlpp struct on_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _is_dynamic = is_database; diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index bdd2c312..bc85d708 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -71,7 +71,7 @@ namespace sqlpp struct order_by_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _is_dynamic = is_database; @@ -141,7 +141,7 @@ namespace sqlpp struct no_order_by_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index 0acbba76..d0542a64 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -39,7 +39,7 @@ namespace sqlpp { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _parameters = std::tuple; using _can_be_null = std::true_type; diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h index 56f935d6..7027bbc0 100644 --- a/include/sqlpp11/prepared_execute.h +++ b/include/sqlpp11/prepared_execute.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_execute_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_insert.h b/include/sqlpp11/prepared_insert.h index a44b2214..416b46de 100644 --- a/include/sqlpp11/prepared_insert.h +++ b/include/sqlpp11/prepared_insert.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_insert_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_remove.h b/include/sqlpp11/prepared_remove.h index 0c67cd61..3d75c9e0 100644 --- a/include/sqlpp11/prepared_remove.h +++ b/include/sqlpp11/prepared_remove.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_remove_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_select.h b/include/sqlpp11/prepared_select.h index 112586f7..5d5893f5 100644 --- a/include/sqlpp11/prepared_select.h +++ b/include/sqlpp11/prepared_select.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_select_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _result_row_t = typename Statement::template _result_row_t; using _parameter_list_t = make_parameter_list_t; diff --git a/include/sqlpp11/prepared_update.h b/include/sqlpp11/prepared_update.h index c9190188..cac4af4b 100644 --- a/include/sqlpp11/prepared_update.h +++ b/include/sqlpp11/prepared_update.h @@ -37,7 +37,7 @@ namespace sqlpp struct prepared_update_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/result_field_methods.h b/include/sqlpp11/result_field_methods.h index 2e7ec984..850d1f43 100644 --- a/include/sqlpp11/result_field_methods.h +++ b/include/sqlpp11/result_field_methods.h @@ -81,7 +81,7 @@ namespace sqlpp tag::is_expression, tag_if>; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _can_be_null = column_spec_can_be_null_t<_field_spec_t>; }; diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index f814037e..02924a01 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -185,7 +185,7 @@ namespace sqlpp struct _field_spec_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; struct _alias_t {}; }; diff --git a/include/sqlpp11/rhs_wrap.h b/include/sqlpp11/rhs_wrap.h index 54c1e114..d48f6c22 100644 --- a/include/sqlpp11/rhs_wrap.h +++ b/include/sqlpp11/rhs_wrap.h @@ -118,7 +118,7 @@ namespace sqlpp struct rhs_wrap_t { using _traits = typename Expr::_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; rhs_wrap_t(Expr expr): _expr(expr) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index ea38d3a5..0a5b5e74 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -164,7 +164,7 @@ namespace sqlpp struct select_column_list_t { using _traits = typename detail::select_traits::_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _alias_t = typename detail::select_traits::_alias_t; @@ -353,7 +353,7 @@ namespace sqlpp struct no_select_column_list_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; struct _alias_t {}; diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 1c3f84bf..1cd4fc5f 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -60,7 +60,7 @@ namespace sqlpp struct select_flag_list_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _is_dynamic = is_database; @@ -128,7 +128,7 @@ namespace sqlpp struct no_select_flag_list_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index 65a75fb5..c9210486 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -38,7 +38,7 @@ namespace sqlpp struct all_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; }; static constexpr all_t all = {}; @@ -57,7 +57,7 @@ namespace sqlpp struct distinct_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; }; static constexpr distinct_t distinct = {}; @@ -76,7 +76,7 @@ namespace sqlpp struct straight_join_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; }; static constexpr straight_join_t straight_join = {}; diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 5953ad30..2f027dd0 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -58,7 +58,7 @@ namespace sqlpp NamedExpr...>, select_column_spec_t...> { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; select_pseudo_table_t(Select select): _select(select) diff --git a/include/sqlpp11/simple_column.h b/include/sqlpp11/simple_column.h index 26e7062f..c5442a61 100644 --- a/include/sqlpp11/simple_column.h +++ b/include/sqlpp11/simple_column.h @@ -39,7 +39,7 @@ namespace sqlpp _column_t _column; using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; }; template diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index c22c1aa4..dc9b7798 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -58,7 +58,7 @@ namespace sqlpp struct single_table_t { using _traits = make_traits; - using _nodes = std::tuple
; + using _nodes = detail::type_vector
; static_assert(is_table_t
::value, "argument has to be a table"); static_assert(required_tables_of
::size::value == 0, "table depends on another table"); @@ -99,7 +99,7 @@ namespace sqlpp struct no_single_table_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/some.h b/include/sqlpp11/some.h index 9747ebcb..1800e974 100644 --- a/include/sqlpp11/some.h +++ b/include/sqlpp11/some.h @@ -37,7 +37,7 @@ namespace sqlpp struct some_t { using _traits = make_traits, tag::is_multi_expression>; - using _nodes = std::tuple; struct _alias_t { diff --git a/include/sqlpp11/sort_order.h b/include/sqlpp11/sort_order.h index 546ff4f1..1dea7449 100644 --- a/include/sqlpp11/sort_order.h +++ b/include/sqlpp11/sort_order.h @@ -42,7 +42,7 @@ namespace sqlpp struct sort_order_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; Expression _expression; }; diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 59ef4a8f..ac47c2c4 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -148,7 +148,7 @@ namespace sqlpp using _traits = make_traits<_value_type, tag_if::value>>; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _can_be_null = logic::any_t< can_be_null_t<_result_type_provider>::value, detail::make_intersect_set_t< @@ -201,7 +201,7 @@ namespace sqlpp tag_if::value>, tag_if::value>::value>, tag::requires_braces>; - using _nodes = std::tuple<_policies_t>; + using _nodes = detail::type_vector<_policies_t>; using _used_outer_tables = typename _policies_t::_all_provided_outer_tables; using _alias_t = typename _result_type_provider::_alias_t; @@ -275,7 +275,7 @@ namespace sqlpp struct statement_name_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = NameData; diff --git a/include/sqlpp11/sum.h b/include/sqlpp11/sum.h index e23f6fb9..b766d2e3 100644 --- a/include/sqlpp11/sum.h +++ b/include/sqlpp11/sum.h @@ -38,7 +38,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _nodes = std::tuple; + using _nodes = detail::type_vector; static_assert(is_noop::value or std::is_same::value, "sum() used with flag other than 'distinct'"); static_assert(is_numeric_t::value, "sum() requires a numeric expression as argument"); diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 06b2aa93..a7a22b65 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -46,7 +46,7 @@ namespace sqlpp { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _provided_tables = detail::type_set
; static_assert(sizeof...(ColumnSpec), "at least one column required per table"); diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 44277b71..2452ec6c 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -42,7 +42,7 @@ namespace sqlpp //FIXME: Need to add join functionality using _traits = make_traits, tag::is_table, tag::is_alias, tag_if::value>>; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _required_ctes = required_ctes_of
; using _provided_tables = detail::type_set; diff --git a/include/sqlpp11/tvin.h b/include/sqlpp11/tvin.h index c5c1ad7d..9c4b3c1a 100644 --- a/include/sqlpp11/tvin.h +++ b/include/sqlpp11/tvin.h @@ -40,7 +40,7 @@ namespace sqlpp struct tvin_arg_t { using _traits = make_traits, tag::is_expression>; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _operand_t = Operand; @@ -102,7 +102,7 @@ namespace sqlpp struct tvin_t { using _traits = make_traits, tag::is_expression>; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _operand_t = Operand; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 2a897c4b..763381a5 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -179,7 +180,7 @@ namespace sqlpp using type = typename T::_##trait;\ };\ template\ - struct trait##_of_impl, void>\ + struct trait##_of_impl, void>\ {\ using type = detail::make_joined_set_t::type...>;\ };\ @@ -208,7 +209,7 @@ namespace sqlpp using type = typename T::_##trait;\ };\ template\ - struct trait##_impl, void>\ + struct trait##_impl, void>\ {\ using type = logic::any_t::type::value...>;\ };\ @@ -232,7 +233,7 @@ namespace sqlpp using type = typename T::_parameters; }; template - struct parameters_of_impl, void> + struct parameters_of_impl, void> { using type = detail::make_parameter_tuple_t::type...>; }; @@ -255,7 +256,7 @@ namespace sqlpp struct aggregate_function { - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _contains_aggregate_function = std::true_type; }; diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 22023b32..199c0aa8 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -66,7 +66,7 @@ namespace sqlpp struct union_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _alias_t = struct{}; @@ -114,7 +114,7 @@ namespace sqlpp struct no_union_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 324a8284..d2e3cd9e 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -68,7 +68,7 @@ namespace sqlpp struct update_list_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _is_dynamic = is_database; // Data @@ -153,7 +153,7 @@ namespace sqlpp struct no_update_list_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index 7f8b78fd..10018e14 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -58,7 +58,7 @@ namespace sqlpp struct using_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _is_dynamic = is_database; @@ -121,7 +121,7 @@ namespace sqlpp struct no_using_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/value_or_null.h b/include/sqlpp11/value_or_null.h index 8c78c698..ab8fb6a7 100644 --- a/include/sqlpp11/value_or_null.h +++ b/include/sqlpp11/value_or_null.h @@ -51,7 +51,7 @@ namespace sqlpp using _cpp_value_type = typename ValueType::_cpp_value_type; using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; value_or_null_t(_cpp_value_type value): _value(value), diff --git a/include/sqlpp11/verbatim.h b/include/sqlpp11/verbatim.h index b65ec3d8..63ef533e 100644 --- a/include/sqlpp11/verbatim.h +++ b/include/sqlpp11/verbatim.h @@ -39,7 +39,7 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _can_be_null = std::true_type; // since we do not know what's going on inside the verbatim, we assume it can be null verbatim_t(std::string verbatim): _verbatim(verbatim) {} diff --git a/include/sqlpp11/verbatim_table.h b/include/sqlpp11/verbatim_table.h index 2b23e761..9247d3a6 100644 --- a/include/sqlpp11/verbatim_table.h +++ b/include/sqlpp11/verbatim_table.h @@ -50,7 +50,7 @@ namespace sqlpp struct verbatim_table_t: public table_t { - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; struct _alias_t { diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index a8145c06..e3828696 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -71,7 +71,7 @@ namespace sqlpp struct where_t { using _traits = make_traits; - using _nodes = std::tuple; + using _nodes = detail::type_vector; using _is_dynamic = is_database; @@ -149,7 +149,7 @@ namespace sqlpp struct where_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = where_data_t; @@ -198,7 +198,7 @@ namespace sqlpp struct no_where_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index e736f561..efbc9b48 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -66,7 +66,7 @@ namespace sqlpp struct with_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _provided_ctes = detail::make_joined_set_t...>; // with provides common table expressions using _parameters = detail::make_parameter_tuple_t...>; @@ -108,7 +108,7 @@ namespace sqlpp struct no_with_t { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; // Data using _data_t = no_data_t; diff --git a/include/sqlpp11/wrap_operand.h b/include/sqlpp11/wrap_operand.h index 7cbdcb9f..f8a4fc77 100644 --- a/include/sqlpp11/wrap_operand.h +++ b/include/sqlpp11/wrap_operand.h @@ -43,7 +43,7 @@ namespace sqlpp struct boolean_operand: public alias_operators { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _value_t = bool; @@ -82,7 +82,7 @@ namespace sqlpp struct integral_operand: public alias_operators { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _value_t = int64_t; @@ -122,7 +122,7 @@ namespace sqlpp struct floating_point_operand: public alias_operators { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _value_t = double; @@ -161,7 +161,7 @@ namespace sqlpp struct text_operand: public alias_operators { using _traits = make_traits; - using _nodes = std::tuple<>; + using _nodes = detail::type_vector<>; using _value_t = std::string; From cc829a8704508966657d74e3b5a87e64b81cc04b Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 17 Feb 2015 21:39:54 +0100 Subject: [PATCH 094/105] Replaced parameter tuple with paramter type vector --- include/sqlpp11/cte.h | 2 +- include/sqlpp11/custom_query.h | 2 +- include/sqlpp11/detail/type_vector.h | 47 ++++++++++++++++++++++++++++ include/sqlpp11/parameter.h | 2 +- include/sqlpp11/parameter_list.h | 4 +-- include/sqlpp11/statement.h | 6 ++-- include/sqlpp11/type_traits.h | 7 +---- include/sqlpp11/with.h | 4 +-- tests/PreparedTest.cpp | 32 ++++++++++++------- 9 files changed, 78 insertions(+), 28 deletions(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 376b262d..520d353f 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -45,7 +45,7 @@ namespace sqlpp { using _nodes = detail::type_vector<>; using _required_ctes = detail::make_joined_set_t, required_ctes_of>; - using _parameters = detail::make_parameter_tuple_t, parameters_of>; + using _parameters = detail::type_vector_cat_t, parameters_of>; cte_union_t(Lhs lhs, Rhs rhs): _lhs(lhs), diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 792be16a..1868073b 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -56,7 +56,7 @@ namespace sqlpp using _traits = make_traits; using _nodes = detail::type_vector; - using _parameter_check = typename std::conditional>::value == 0, + using _parameter_check = typename std::conditional>::value == 0, consistent_t, assert_no_parameters_t>::type; using _run_check = detail::get_first_if; diff --git a/include/sqlpp11/detail/type_vector.h b/include/sqlpp11/detail/type_vector.h index 06e41d25..7b23b8c8 100644 --- a/include/sqlpp11/detail/type_vector.h +++ b/include/sqlpp11/detail/type_vector.h @@ -27,6 +27,8 @@ #ifndef SQLPP_DETAIL_TYPE_VECTOR_H #define SQLPP_DETAIL_TYPE_VECTOR_H +#include + namespace sqlpp { namespace detail @@ -34,6 +36,51 @@ namespace sqlpp template struct type_vector {}; + + template + struct type_vector_cat_impl + { + static_assert(wrong_t::value, "type_vector_cat must be called with type_vector arguments"); + }; + + template<> + struct type_vector_cat_impl<> + { + using type = type_vector<>; + }; + + template + struct type_vector_cat_impl> + { + using type = type_vector; + }; + + template + struct type_vector_cat_impl, type_vector> + { + using type = type_vector; + }; + + template + struct type_vector_cat_impl, Rest...> + { + using type = typename type_vector_cat_impl, typename type_vector_cat_impl::type>::type; + }; + + template + using type_vector_cat_t = typename type_vector_cat_impl::type; + + template + struct type_vector_size + { + static_assert(wrong_t::value, "type_vector_size needs to be called with a type_vector argument"); + }; + + template + struct type_vector_size> + { + static constexpr std::size_t value = sizeof...(T); + }; } } diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index d0542a64..13447233 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -40,7 +40,7 @@ namespace sqlpp using _traits = make_traits; using _nodes = detail::type_vector<>; - using _parameters = std::tuple; + using _parameters = detail::type_vector; using _can_be_null = std::true_type; using _instance_t = member_t>; diff --git a/include/sqlpp11/parameter_list.h b/include/sqlpp11/parameter_list.h index b185bf73..eaace254 100644 --- a/include/sqlpp11/parameter_list.h +++ b/include/sqlpp11/parameter_list.h @@ -37,11 +37,11 @@ namespace sqlpp template struct parameter_list_t { - static_assert(wrong_t::value, "Template parameter for parameter_list_t has to be a tuple"); + static_assert(wrong_t::value, "Template parameter for parameter_list_t has to be a type_vector"); }; template - struct parameter_list_t>: public Parameter::_instance_t... + struct parameter_list_t>: public Parameter::_instance_t... { using _member_tuple_t = std::tuple; using size = std::integral_constant; diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index ac47c2c4..fce7109b 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -155,14 +155,14 @@ namespace sqlpp required_tables_of<_result_type_provider>, _all_provided_outer_tables >::size::value != 0>; - using _parameters = detail::make_parameter_tuple_t...>; + using _parameters = detail::type_vector_cat_t...>; // required_tables and _required_ctes are defined above using _cte_check = typename std::conditional<_required_ctes::size::value == 0, consistent_t, assert_no_unknown_ctes_t>::type; using _table_check = typename std::conditional<_required_tables::size::value == 0, consistent_t, assert_no_unknown_tables_t>::type; - using _parameter_check = typename std::conditional::value == 0, + using _parameter_check = typename std::conditional::value == 0, consistent_t, assert_no_parameters_t>::type; }; } @@ -226,7 +226,7 @@ namespace sqlpp static constexpr size_t _get_static_no_of_parameters() { - return std::tuple_size>::value; + return detail::type_vector_size>::value; } size_t _get_no_of_parameters() const diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 763381a5..389edd0a 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -155,11 +155,6 @@ namespace sqlpp template using is_database = typename std::conditional::value, std::false_type, std::true_type>::type; - namespace detail - { - template - using make_parameter_tuple_t = decltype(std::tuple_cat(std::declval()...)); - } template using value_type_of = typename T::_traits::_value_type; @@ -235,7 +230,7 @@ namespace sqlpp template struct parameters_of_impl, void> { - using type = detail::make_parameter_tuple_t::type...>; + using type = detail::type_vector_cat_t::type...>; }; } template\ diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index efbc9b48..c2e0a725 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -67,8 +67,8 @@ namespace sqlpp { using _traits = make_traits; using _nodes = detail::type_vector<>; - using _provided_ctes = detail::make_joined_set_t...>; // with provides common table expressions - using _parameters = detail::make_parameter_tuple_t...>; + using _provided_ctes = detail::make_joined_set_t...>; // WITH provides common table expressions + using _parameters = detail::type_vector_cat_t...>; using _is_dynamic = is_database; diff --git a/tests/PreparedTest.cpp b/tests/PreparedTest.cpp index 87b47311..8e4c79df 100644 --- a/tests/PreparedTest.cpp +++ b/tests/PreparedTest.cpp @@ -40,40 +40,48 @@ int main() // empty parameter lists { - using T = sqlpp::parameters_of; - static_assert(std::is_same>::value, "type requirement"); + using T = sqlpp::make_parameter_list_t; + static_assert(T::size::value == 0, "type requirement"); } // single parameter { - using T = sqlpp::parameters_of; - static_assert(std::is_same>::value, "type requirement"); + using T = sqlpp::make_parameter_list_t; + static_assert(T::size::value == 1, "type requirement"); + auto t = T{}; + t.alpha = 7; } // single parameter { - using T = sqlpp::parameters_of; - static_assert(std::is_same>::value, "type requirement"); + using T = sqlpp::make_parameter_list_t; + static_assert(T::size::value == 1, "type requirement"); + auto t = T{}; + t.beta = "cheesecake"; } // single parameter in expression { - using T = sqlpp::parameters_of; - static_assert(std::is_same>::value, "type requirement"); + using T = sqlpp::make_parameter_list_t; + static_assert(T::size::value == 1, "type requirement"); + auto t = T{}; + t.alpha = 7; } // single parameter in larger expression { - using T = sqlpp::parameters_of; - static_assert(std::is_same>::value, "type requirement"); + using T = sqlpp::make_parameter_list_t; + static_assert(T::size::value == 1, "type requirement"); + auto t = T{}; + t.alpha = 7; } // three parameters in expression { using T = sqlpp::parameters_of; - static_assert(std::tuple_size::value == 3, "type requirement"); - static_assert(std::is_same>::value, "type requirement"); + // FIXME: make some test, that does not depend on detail namespace, but still checks the correct order of the parameters + static_assert(std::is_same>::value, "type requirement"); } // OK, fine, now create a named parameter list from an expression From c9401d4b008d9490081cb99a226214aad3ccba6e Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 17 Feb 2015 22:14:05 +0100 Subject: [PATCH 095/105] Cleaned up requirements for sub-selects as tables --- include/sqlpp11/statement.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index fce7109b..863ef6ed 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -130,14 +130,12 @@ namespace sqlpp // A select can be used as a pseudo table if // - at least one column is selected - // - the select is complete (leaks no table requirements) + // - the select is complete (leaks no table requirements or cte requirements) static constexpr bool _can_be_used_as_table() { return has_result_row_t<_statement_t>::value and _required_tables::size::value == 0 - and _all_provided_ctes::size::value == 0 // a sub-select must not contain a WITH - ? true - : false; + and _required_ctes::size::value == 0; } using _value_type = typename std::conditional< From 57ceefbd0c306c521726187ce554bcaba9937966 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 24 Feb 2015 08:02:14 +0100 Subject: [PATCH 096/105] Added missing checks for aggregate functions --- include/sqlpp11/count.h | 4 +++- include/sqlpp11/max.h | 1 + include/sqlpp11/min.h | 1 + test_constraints/CMakeLists.txt | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index f2801f98..7abda19f 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -40,7 +40,7 @@ namespace sqlpp { using _traits = make_traits; - using _nodes = detail::type_vector; + using _nodes = detail::type_vector; using _can_be_null = std::false_type; static_assert(is_noop::value or std::is_same::value, "count() used with flag other than 'distinct'"); @@ -98,6 +98,7 @@ namespace sqlpp template auto count(T t) -> count_t> { + static_assert(not contains_aggregate_function_t>::value, "count() cannot be used on an aggregate function"); static_assert(is_expression_t>::value, "count() requires an expression as argument"); return { t }; } @@ -105,6 +106,7 @@ namespace sqlpp template auto count(const distinct_t&, T t) -> count_t> { + static_assert(not contains_aggregate_function_t>::value, "count() cannot be used on an aggregate function"); static_assert(is_expression_t>::value, "count() requires an expression as argument"); return { t }; } diff --git a/include/sqlpp11/max.h b/include/sqlpp11/max.h index c497a56d..f2011988 100644 --- a/include/sqlpp11/max.h +++ b/include/sqlpp11/max.h @@ -84,6 +84,7 @@ namespace sqlpp template auto max(T t) -> max_t> { + static_assert(not contains_aggregate_function_t>::value, "max() cannot be used on an aggregate function"); static_assert(is_expression_t>::value, "max() requires an expression as argument"); return { t }; } diff --git a/include/sqlpp11/min.h b/include/sqlpp11/min.h index 95649823..7f885c07 100644 --- a/include/sqlpp11/min.h +++ b/include/sqlpp11/min.h @@ -84,6 +84,7 @@ namespace sqlpp template auto min(T t) -> min_t> { + static_assert(not contains_aggregate_function_t>::value, "min() cannot be used on an aggregate function"); static_assert(is_expression_t>::value, "min() requires an expression as argument"); return { t }; } diff --git a/test_constraints/CMakeLists.txt b/test_constraints/CMakeLists.txt index 2281b371..d36c597f 100644 --- a/test_constraints/CMakeLists.txt +++ b/test_constraints/CMakeLists.txt @@ -24,8 +24,8 @@ function(test_constraint name pattern) endfunction(test_constraint) -test_constraint(count_of_count "requires an expression as argument") -test_constraint(max_of_max "requires an expression as argument") +test_constraint(count_of_count "count() cannot be used on an aggregate function") +test_constraint(max_of_max "max() cannot be used on an aggregate function") test_constraint(no_conversion_operator_if_null_not_trivial "int i = row.alpha") test_constraint(require_insert "required column is missing") test_constraint(must_not_insert "one assignment is prohibited") From 8910220b6c517ebb0abecad267d67a630c242e67 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 24 Feb 2015 08:09:17 +0100 Subject: [PATCH 097/105] Minor cleanup --- include/sqlpp11/type_traits.h | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 389edd0a..74cad854 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -51,23 +51,6 @@ namespace sqlpp template using column_spec_can_be_null_t = typename detail::column_spec_can_be_null_impl::type; - namespace tag - { - struct is_expression{}; - } - namespace detail - { - template - struct is_expression_impl { using type = std::false_type; }; - template - struct is_expression_impl::value - //and not detail::is_element_of::value FIXME: Needed here? - >::type> { using type = std::true_type; }; - } - template - using is_expression_t = typename detail::is_expression_impl::type; - #define SQLPP_VALUE_TRAIT_GENERATOR(name) \ namespace tag\ {\ @@ -96,6 +79,7 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(is_text) SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value) SQLPP_VALUE_TRAIT_GENERATOR(is_selectable) + SQLPP_VALUE_TRAIT_GENERATOR(is_expression) SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression) SQLPP_VALUE_TRAIT_GENERATOR(is_alias) SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag) From 3b2f666b53338cd40d292e75e876d47161558202 Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 4 Mar 2015 07:43:15 +0100 Subject: [PATCH 098/105] Fixed serialization of recursive common table expressions --- include/sqlpp11/cte.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index 520d353f..85105317 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -71,13 +71,11 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - context << '('; serialize(t._lhs, context); - context << ") UNION "; + context << " UNION "; serialize(Flag{}, context); - context << " ("; + context << " "; serialize(t._rhs, context); - context << ')'; return context; } }; From 0c429928cdbabb53da414bc81dd8b9a83fa7a722 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 5 Mar 2015 18:01:27 +0100 Subject: [PATCH 099/105] Fixed ctest config --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4db91ca9..6bede25b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,7 +3,7 @@ macro (build arg) # Add headers to sources to enable file browsing in IDEs include_directories("${CMAKE_SOURCE_DIR}/tests") add_executable("Sqlpp11Example${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_SOURCE_DIR}/tests/MockDb.h" "${CMAKE_CURRENT_LIST_DIR}/Sample.h") - add_test("${arg}" "${arg}") + add_test("${arg}" "Sqlpp11Example${arg}") endmacro () #build(sample) From 028af83fe78feb000331877d1b025262396e3910 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 5 Mar 2015 18:01:59 +0100 Subject: [PATCH 100/105] Fixed UNION DISTINCT to not serialize DISTINCT sqlite3 does not support the keyword in UNION, and for others DISTINCT is the default anywy --- include/sqlpp11/type_traits.h | 1 + include/sqlpp11/union.h | 10 ++--- include/sqlpp11/union_data.h | 6 +-- include/sqlpp11/union_flags.h | 75 +++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 include/sqlpp11/union_flags.h diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 74cad854..8610532a 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -83,6 +83,7 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression) SQLPP_VALUE_TRAIT_GENERATOR(is_alias) SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag) + SQLPP_VALUE_TRAIT_GENERATOR(is_union_flag) SQLPP_VALUE_TRAIT_GENERATOR(is_result_field) SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert) diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 199c0aa8..f8daf2f2 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -28,7 +28,7 @@ #define SQLPP_UNION_H #include -#include +#include #include #include #include @@ -154,7 +154,7 @@ namespace sqlpp template auto union_distinct(Rhs rhs) const - -> _new_statement_t<_check, union_t, Rhs>> + -> _new_statement_t<_check, union_t, Rhs>> { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); @@ -165,12 +165,12 @@ namespace sqlpp static_assert(std::is_same>, _result_row_t>::value, "both arguments in a union have to have the same result columns (type and name)"); static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); - return _union_impl(_check, Rhs>{}, rhs); + return _union_impl(_check, Rhs>{}, rhs); } template auto union_all(Rhs rhs) const - -> _new_statement_t<_check, union_t, Rhs>> + -> _new_statement_t<_check, union_t, Rhs>> { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); @@ -181,7 +181,7 @@ namespace sqlpp static_assert(std::is_same>, _result_row_t>::value, "both arguments in a union have to have the same result columns (type and name)"); static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); - return _union_impl(_check, Rhs>{}, rhs); + return _union_impl(_check, Rhs>{}, rhs); } private: diff --git a/include/sqlpp11/union_data.h b/include/sqlpp11/union_data.h index 55379046..f1c02f4a 100644 --- a/include/sqlpp11/union_data.h +++ b/include/sqlpp11/union_data.h @@ -58,13 +58,11 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - context << '('; serialize(t._lhs, context); - context << ") UNION "; + context << " UNION "; serialize(Flag{}, context); - context << " ("; + context << " "; serialize(t._rhs, context); - context << ')'; return context; } }; diff --git a/include/sqlpp11/union_flags.h b/include/sqlpp11/union_flags.h new file mode 100644 index 00000000..9d2ded02 --- /dev/null +++ b/include/sqlpp11/union_flags.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNION_FLAGS_H +#define SQLPP_UNION_FLAGS_H + +#include +#include +#include +#include + +namespace sqlpp +{ + // standard select flags + struct union_all_t + { + using _traits = make_traits; + using _nodes = detail::type_vector<>; + }; + + template + struct serializer_t + { + using _serialize_check = consistent_t; + + static Context& _(const union_all_t&, Context& context) + { + context << "ALL"; + return context; + } + }; + + struct union_distinct_t + { + using _traits = make_traits; + using _nodes = detail::type_vector<>; + }; + + template + struct serializer_t + { + using _serialize_check = consistent_t; + + static Context& _(const union_distinct_t&, Context& context) + { + return context; + } + }; + +} + +#endif From 6591d38babccf96cdf395f70ca59a282633b2a39 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 7 Mar 2015 09:40:06 +0100 Subject: [PATCH 101/105] Added table() method for columns. --- include/sqlpp11/column.h | 7 +++++++ tests/SelectTest.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 8a6911bc..bb0dd740 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -70,6 +70,13 @@ namespace sqlpp column_t& operator=(column_t&&) = default; ~column_t() = default; + template + auto table() const -> _table + { + static_assert(is_table_t::value, "cannot call get_table for columns of a sub-selects or cte"); + return _table{}; + } + template expression_alias_t as(const alias_provider&) const { diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index b804aee1..86ad502f 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -36,11 +36,23 @@ MockDb db = {}; MockDb::_serializer_context_t printer; +template +int64_t getColumn(const Column& column) +{ + auto result = db(select(column.as(sqlpp::a)).from(column.table()).where(true)); + if (not result.empty()) + return result.front().a; + else + return 0; +} + int main() { test::TabFoo f; test::TabBar t; + getColumn(t.alpha); + for (const auto& row : db(select(all_of(t)).from(t).where(true))) { int64_t a = row.alpha; From d2975b39fb7fe9b78cd7aef416011c82fb7da3ee Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 8 Mar 2015 18:36:42 +0100 Subject: [PATCH 102/105] Allow sqlpp be compiled as sub project --- examples/CMakeLists.txt | 4 ++-- test_constraints/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6bede25b..33b8e65f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,8 +1,8 @@ macro (build arg) # Add headers to sources to enable file browsing in IDEs - include_directories("${CMAKE_SOURCE_DIR}/tests") - add_executable("Sqlpp11Example${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_SOURCE_DIR}/tests/MockDb.h" "${CMAKE_CURRENT_LIST_DIR}/Sample.h") + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../tests") + add_executable("Sqlpp11Example${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_CURRENT_SOURCE_DIR}/../tests/MockDb.h" "${CMAKE_CURRENT_LIST_DIR}/Sample.h") add_test("${arg}" "Sqlpp11Example${arg}") endmacro () diff --git a/test_constraints/CMakeLists.txt b/test_constraints/CMakeLists.txt index d36c597f..20e699d9 100644 --- a/test_constraints/CMakeLists.txt +++ b/test_constraints/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories("${CMAKE_SOURCE_DIR}/tests") +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../tests") add_custom_target(test_sqlpp_constraints COMMAND true) From 30834ab9db1d766f21d31909e7c939120adc941e Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 8 Mar 2015 20:15:16 +0100 Subject: [PATCH 103/105] Fixed value_list for sets --- include/sqlpp11/functions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 143ddc61..46776612 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -109,7 +109,7 @@ namespace sqlpp { if (t._container.size() == 1) { - return serialize(value(t._container[0]), context); + return serialize(value(*begin(t._container)), context); } bool first = true; From 47150e1fdbc6f9619c7f1b4ab56c6a2bd10beb83 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 8 Mar 2015 20:17:10 +0100 Subject: [PATCH 104/105] Added missing inline to free function --- include/sqlpp11/verbatim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/verbatim.h b/include/sqlpp11/verbatim.h index 63ef533e..4ea31b51 100644 --- a/include/sqlpp11/verbatim.h +++ b/include/sqlpp11/verbatim.h @@ -71,7 +71,7 @@ namespace sqlpp return { s }; } - auto verbatim(std::string s) -> verbatim_t + inline auto verbatim(std::string s) -> verbatim_t { return { s }; } From 21621f81c8f77ed06ff0ec52f63f683732c6729e Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 8 Mar 2015 20:19:01 +0100 Subject: [PATCH 105/105] Added -Wshadow and un-inlined namespace alias Not sure if inlining alias was a good idea to begin with... --- CMakeLists.txt | 2 +- include/sqlpp11/alias_provider.h | 2 +- tests/PreparedTest.cpp | 48 ++++++++++++++++---------------- tests/SelectTest.cpp | 2 +- tests/WithTest.cpp | 4 +-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e44621d2..4f5266c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") endif () -set(CMAKE_CXX_FLAGS "-Wconversion -Wpedantic ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "-Wconversion -Wpedantic -Wshadow ${CMAKE_CXX_FLAGS}") set(include_dir "${PROJECT_SOURCE_DIR}/include") file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h") diff --git a/include/sqlpp11/alias_provider.h b/include/sqlpp11/alias_provider.h index ada9ea1d..86dba643 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -62,7 +62,7 @@ namespace sqlpp static constexpr bool value = true; }; - inline namespace alias + namespace alias { SQLPP_ALIAS_PROVIDER(a) SQLPP_ALIAS_PROVIDER(b) diff --git a/tests/PreparedTest.cpp b/tests/PreparedTest.cpp index 8e4c79df..82c7fe4e 100644 --- a/tests/PreparedTest.cpp +++ b/tests/PreparedTest.cpp @@ -40,55 +40,55 @@ int main() // empty parameter lists { - using T = sqlpp::make_parameter_list_t; - static_assert(T::size::value == 0, "type requirement"); + using P = sqlpp::make_parameter_list_t; + static_assert(P::size::value == 0, "type requirement"); } // single parameter { - using T = sqlpp::make_parameter_list_t; - static_assert(T::size::value == 1, "type requirement"); - auto t = T{}; - t.alpha = 7; + using P = sqlpp::make_parameter_list_t; + static_assert(P::size::value == 1, "type requirement"); + auto p = P{}; + p.alpha = 7; } // single parameter { - using T = sqlpp::make_parameter_list_t; - static_assert(T::size::value == 1, "type requirement"); - auto t = T{}; - t.beta = "cheesecake"; + using P = sqlpp::make_parameter_list_t; + static_assert(P::size::value == 1, "type requirement"); + auto p = P{}; + p.beta = "cheesecake"; } // single parameter in expression { - using T = sqlpp::make_parameter_list_t; - static_assert(T::size::value == 1, "type requirement"); - auto t = T{}; - t.alpha = 7; + using P = sqlpp::make_parameter_list_t; + static_assert(P::size::value == 1, "type requirement"); + auto p = P{}; + p.alpha = 7; } // single parameter in larger expression { - using T = sqlpp::make_parameter_list_t; - static_assert(T::size::value == 1, "type requirement"); - auto t = T{}; - t.alpha = 7; + using P = sqlpp::make_parameter_list_t; + static_assert(P::size::value == 1, "type requirement"); + auto p = P{}; + p.alpha = 7; } // three parameters in expression { - using T = sqlpp::parameters_of; + using P = sqlpp::parameters_of; // FIXME: make some test, that does not depend on detail namespace, but still checks the correct order of the parameters - static_assert(std::is_same>::value, "type requirement"); + static_assert(std::is_same>::value, "type requirement"); } // OK, fine, now create a named parameter list from an expression { using Exp = decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma)); - using T = sqlpp::make_parameter_list_t; - T npl; + using P = sqlpp::make_parameter_list_t; + P npl; static_assert(std::is_same>, decltype(npl.alpha)>::value, "type requirement"); static_assert(std::is_same>, decltype(npl.beta)>::value, "type requirement"); static_assert(std::is_same>, decltype(npl.gamma)>::value, "type requirement"); @@ -101,8 +101,8 @@ int main() p.params.alpha = 7; p.params.alpha = sqlpp::tvin(0); using S = decltype(s); - using T = sqlpp::make_parameter_list_t; - T npl; + using P = sqlpp::make_parameter_list_t; + P npl; static_assert(std::is_same>, decltype(npl.alpha)>::value, "type requirement"); static_assert(std::is_same>, decltype(npl.beta)>::value, "type requirement"); diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index 86ad502f..ba5f9bec 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -39,7 +39,7 @@ MockDb::_serializer_context_t printer; template int64_t getColumn(const Column& column) { - auto result = db(select(column.as(sqlpp::a)).from(column.table()).where(true)); + auto result = db(select(column.as(sqlpp::alias::a)).from(column.table()).where(true)); if (not result.empty()) return result.front().a; else diff --git a/tests/WithTest.cpp b/tests/WithTest.cpp index 81a172ad..639d3efa 100644 --- a/tests/WithTest.cpp +++ b/tests/WithTest.cpp @@ -36,11 +36,11 @@ int main() { const auto t = test::TabBar{}; - auto x = cte(sqlpp::x).as(select(all_of(t)).from(t)); + auto x = sqlpp::cte(sqlpp::alias::x).as(select(all_of(t)).from(t)); db(with(x)(select(x.alpha).from(x).where(true))); - auto y0 = cte(sqlpp::y).as(select(all_of(t)).from(t)); + auto y0 = sqlpp::cte(sqlpp::alias::y).as(select(all_of(t)).from(t)); auto y = y0.union_all(select(all_of(y0)).from(y0).where(false)); std::cout << serialize(y, printer).str() << std::endl; printer.reset();