diff --git a/connector_api/bind_result.h b/connector_api/bind_result.h new file mode 100644 index 00000000..8999c357 --- /dev/null +++ b/connector_api/bind_result.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2013, 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_DATABASE_BIND_RESULT_H +#define SQLPP_DATABASE_BIND_RESULT_H + +#include + +namespace sqlpp +{ + namespace database + { + /* + * bind_result_t binds values of a sqlpp11 result row + * to the results of a statement + */ + class bind_result_t + { + public: + bind_result_t(); // default constructor for a result that will not yield a valid row + bind_result_t(...); + bind_result_t(const bind_result_t&) = delete; + bind_result_t(bind_result_t&& rhs); + bind_result_t& operator=(const bind_result_t&) = delete; + bind_result_t& operator=(bind_result_t&&); + ~bind_result_t(); + + bool operator==(const bind_result_t& rhs) const; + + template + void next(ResultRow& result_row); + + // something similar to this: + /* + { + if (!_handle) + { + result_row.invalidate(); + return; + } + + if (next_impl()) + { + if (not result_row) + { + result_row.validate(); + } + result_row._bind(*this); // bind result row values to results + } + else + { + if (result_row) + result_row.invalidate(); + } + }; + */ + + // These are called by the result row to bind individual result values + void _bind_boolean_result(size_t index, signed char* value, bool* is_null); + void _bind_integral_result(size_t index, int64_t* value, bool* is_null); + void _bind_text_result(size_t index, const char** text, size_t* len); + ... + }; + + } +} +#endif diff --git a/connector_api/char_result.h b/connector_api/char_result.h new file mode 100644 index 00000000..355ba959 --- /dev/null +++ b/connector_api/char_result.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2013, 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_DATABASE_CHAR_RESULT_H +#define SQLPP_DATABASE_CHAR_RESULT_H + +#include + +namespace sqlpp +{ + namespace database + { + /* + * char_result_t yields results as + * sqlpp11::vendor::char_result_row_t + */ + class char_result_t + { + ::sqlpp11::vendor::char_result_row_t char_result_row; + public: + char_result_t(); // default constructor for a result that will not yield a valid row + char_result_t(...); + char_result_t(const char_result_t&) = delete; + char_result_t(char_result_t&& rhs); + char_result_t& operator=(const char_result_t&) = delete; + char_result_t& operator=(char_result_t&&); + ~char_result_t(); + + bool operator==(const char_result_t& rhs) const; + + template + void next(ResultRow& result_row); + + // Something like + /* + { + next_impl(); + if (_char_result_row.data) + result_row = _char_result_row; + else + result_row.invalidate(); + }; + */ + } +} +#endif diff --git a/connector_api/connection.h b/connector_api/connection.h new file mode 100644 index 00000000..d6e98663 --- /dev/null +++ b/connector_api/connection.h @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2013, 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_DATABASE_CONNECTION_H +#define SQLPP_DATABASE_CONNECTION_H + +#include +#include +#include // You may use char result or bind result or both +#include // to represent results of select and prepared select + +namespace sqlpp +{ + namespace database + { + // The context is not a requirement, but if the database requires + // any deviations from the SQL standard, you should use your own + // context in order to specialize the behaviour, see also interpreter.h + struct context_t + { + template + std::ostream& operator<<(T t); + + std::string escape(std::string arg); + }; + + class connection: public sqlpp::connection // this inheritance helps with ADL for dynamic_select, for instance + { + public: + using _prepared_statement_t = << handle to a prepared statement of the database >>; + using _context_t = << This context is used to interpret the dynamic parts of dynamic statemtents>>; + + connection(...); + ~connection(); + connection(const connection&) = delete; + connection(connection&&) = delete; + connection& operator=(const connection&) = delete; + connection& operator=(connection&&) = delete; + + //! "direct" select + template + <> select(const Select& s); + + //! prepared select + template + _prepared_statement_t prepare_select(Select& s); + + template + <> run_prepared_select(const PreparedSelect& s); // call s._bind_params() + + //! "direct insert + template + size_t insert(const Insert& i); + + //! prepared insert + template + _prepared_statement_t prepare_insert(Insert& i); + + template + size_t run_prepared_insert(const PreparedInsert& i); // call i._bind_params() + + //! "direct" update + template + size_t update(const Update& u); + + //! "prepared" update + template + _prepared_statement_t prepare_update(Update& u); + + template + size_t run_prepared_update(const PreparedUpdate& u); // call u._bind_params() + + //! "direct" remove + template + size_t remove(const Remove& r) + + //! prepared remove + template + _prepared_statement_t prepare_remove(Remove& r); + + template + size_t run_prepared_remove(const PreparedRemove& r); // call r._bind_params() + + //! call run on the argument + template + auto run(const T& t) -> decltype(t._run(*this)) + { + return t._run(*this); + } + + //! call prepare on the argument + template + auto prepare(const T& t) -> decltype(t._prepare(*this)) + { + return t._prepare(*this); + } + + //! start transaction + void start_transaction(); + + //! commit transaction (or throw transaction if the transaction has been finished already) + void commit_transaction(); + + //! rollback transaction with or without reporting the rollback (or throw if the transaction has been finished already) + void rollback_transaction(bool report); + + //! report a rollback failure (will be called by transactions in case of a rollback failure in the destructor) + void report_rollback_failure(const std::string message) noexcept; + }; + + } +} + +#include + +#endif diff --git a/connector_api/interpreter.h b/connector_api/interpreter.h new file mode 100644 index 00000000..9a83c008 --- /dev/null +++ b/connector_api/interpreter.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2013, 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_DATABASE_INTERPRETER_H +#define SQLPP_DATABASE_INTERPRETER_H + +#include +#include + +/* + * sqlpp11 offers an interpreter that can be used to serialize the expression tree + * into a standard SQL string. + * + * The connector library can specialize the interpreter template to partially or + * completely change the way the expression tree is interpreted. + * + * For example, this specialization will produce indexed parameters instead of just '?' + */ +namespace sqlpp +{ + namespace vendor + { + template + struct interpreter_t> + { + using T = parameter_t; + + static database::context_t& _(const T& t, database::context_t& context) + { + context << "?" << context.count(); + context.pop_count(); + return context; + } + }; + + } +} + +#endif diff --git a/connector_api/prepared_statement.h b/connector_api/prepared_statement.h new file mode 100644 index 00000000..4a99ee03 --- /dev/null +++ b/connector_api/prepared_statement.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2013, 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_DATABASE_PREPARED_STATEMENT_H +#define SQLPP_DATABASE_PREPARED_STATEMENT_H + +#include +#include + +namespace sqlpp +{ + namespace database + { + class prepared_statement_t + { + public: + prepared_statement_t() = delete; + prepared_statement_t(...); + prepared_statement_t(const prepared_statement_t&) = delete; + prepared_statement_t(prepared_statement_t&& rhs); + prepared_statement_t& operator=(const prepared_statement_t&) = delete; + prepared_statement_t& operator=(prepared_statement_t&&); + ~prepared_statement_t(); + + bool operator==(const prepared_statement_t& rhs) const; + + // These are called by the sqlpp11::prepared_*_t to bind the individual parameters + void _bind_boolean_parameter(size_t index, const signed char* value, bool is_null); + void _bind_integral_parameter(size_t index, const int64_t* value, bool is_null); + void _bind_text_parameter(size_t index, const std::string* value, bool is_null); + }; + } +} +#endif diff --git a/database_api/api.h b/database_api/api.h deleted file mode 100644 index e3519075..00000000 --- a/database_api/api.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2013, 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_DATABASE_API_H -#define SQLPP_DATABASE_API_H - -#include -#include -#include - -namespace sqlpp -{ - namespace connector_name - { - class result - { - public: - result() = default; - result(const result&) = delete; - result(result&& rhs) = default; - result& operator=(const result&) = delete; - result& operator=(result&&) = default; - ~result() = default; - - bool operator==(const result& rhs) const; - - //! return the next row from the result or a "false" row, if there is no next row - sqlpp::raw_result_row_t next(); - size_t num_cols() const; - }; - - class connection: public sqlpp::connection - { - public: - // A bunch of flags telling sqlpp11 which feature is support and which isn't - - // join types - static constexpr bool _supports_inner_join = true; - static constexpr bool _supports_outer_join = true; - static constexpr bool _supports_left_outer_join = true; - static constexpr bool _supports_right_outer_join = true; - - // functions - static constexpr bool _supports_avg = true; - static constexpr bool _supports_count = true; - static constexpr bool _supports_exists = true; - static constexpr bool _supports_like = true; - static constexpr bool _supports_in = true; - static constexpr bool _supports_is_null = true; - static constexpr bool _supports_is_not_null = true; - static constexpr bool _supports_max = true; - static constexpr bool _supports_min = true; - static constexpr bool _supports_not_in = true; - static constexpr bool _supports_sum = true; - - // select - static constexpr bool _supports_group_by = true; - static constexpr bool _supports_having = true; - static constexpr bool _supports_limit = true; - static constexpr bool _supports_order_by = true; - static constexpr bool _supports_select_as_table = true; - - static constexpr bool _supports_some = true; - static constexpr bool _supports_any = true; - static constexpr bool _use_concat_operator = false; - static constexpr bool _use_concat_function = true; - - connection(/*whatever arguments you need*/); - connection(const connection&) = delete; - connection(connection&&) = delete; - connection& operator=(const connection&) = delete; - connection& operator=(connection&&) = delete; - ~connection(); - - //! select returns a result (which can be iterated row by row) - result select(const std::string& query); - - //! insert returns the last auto_incremented id (or zero, if there is none) - size_t insert(const std::string& query); - - //! update returns the number of affected rows - size_t update(const std::string& query); - - //! remove returns the number of removed rows - size_t remove(const std::string& query); - - //! execute arbitrary command (e.g. create a table) - void execute(const std::string& command); - - //! escape given string - std::string escape(const std::string& s) const; - - //! call run on the argument - template - auto run(const T& t) -> decltype(t.run(*this)) - { - return t.run(*this); - } - - //! start transaction - void start_transaction(); - - //! commit transaction (or throw transaction if the transaction has been finished already) - void commit_transaction(); - - //! rollback transaction with or without reporting the rollback (or throw if the transaction has been finished already) - void rollback_transaction(bool report); - - //! report a rollback failure (will be called by transactions in case of a rollback failure in the destructor) - void report_rollback_failure(const std::string message) noexcept; - }; - } -} -#endif diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index f1908e4d..1e5de615 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -44,6 +44,7 @@ namespace sqlpp struct column_t: public ColumnSpec::_value_type::template operators> { using _is_column = std::true_type; + using _spec_t = ColumnSpec; using _table = Table; using _column_type = typename ColumnSpec::_column_type; struct _value_type: ColumnSpec::_value_type diff --git a/include/sqlpp11/detail/logic.h b/include/sqlpp11/detail/logic.h new file mode 100644 index 00000000..72e3a318 --- /dev/null +++ b/include/sqlpp11/detail/logic.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2013, 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_LOGIC_H +#define SQLPP_DETAIL_LOGIC_H + +#include + +namespace sqlpp +{ + namespace detail + { + template + struct and_impl; + + template<> + struct and_impl<> + { + static constexpr bool value = true; + }; + + template + struct and_impl + { + static constexpr bool value = and_impl::value; + }; + + template + struct and_impl + { + static constexpr bool value = false; + }; + + template class Predicate, typename... T> + using and_t = and_impl::value...>; + + template + struct or_impl; + + template<> + struct or_impl<> + { + static constexpr bool value = false; + }; + + template + struct or_impl + { + static constexpr bool value = or_impl::value; + }; + + template + struct or_impl + { + static constexpr bool value = true; + }; + + template class Predicate, typename... T> + using or_t = or_impl::value...>; + + } +} + + +#endif diff --git a/include/sqlpp11/detail/set.h b/include/sqlpp11/detail/set.h deleted file mode 100644 index 2b1a153f..00000000 --- a/include/sqlpp11/detail/set.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2013, 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_SET_H -#define SQLPP_DETAIL_SET_H - -#include -#include - -namespace sqlpp -{ - namespace detail - { - template - struct make_set; - - template - class empty {}; - - template - struct is_superset_of_impl - : std::false_type {}; - - template - struct is_superset_of_impl - : std::true_type {}; - - template - struct is_superset_of_impl - : std::integral_constant::value and is_superset_of_impl::value> {}; - - template - struct is_disjunct_from_impl - : std::false_type {}; - - template - struct is_disjunct_from_impl - : std::true_type {}; - - template - struct is_disjunct_from_impl - : std::integral_constant::value and is_disjunct_from_impl::value> {}; - - template - struct set: empty... - { - struct size: std::integral_constant {}; - - template - struct contains - : std::integral_constant, set>::value> {}; - - template - struct is_superset_of - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_superset_of"); - }; - - template - struct is_superset_of> - : is_superset_of_impl{}; - - template - struct join - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for set::join"); - }; - - template - struct join> - : make_set {}; - - template - struct is_disjunct_from - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_disjunct_from"); - }; - - template - struct is_disjunct_from> - : is_disjunct_from_impl{}; - - template - struct is_subset_of - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_subset_of"); - }; - - template - struct is_subset_of> - : is_superset_of_impl, Element...>{}; - - template - struct equals - { - static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for equals"); - }; - - template - struct equals> - : std::integral_constant, Element...>::value - and - is_superset_of_impl, T...>::value> {}; - - template - struct insert - { - typedef set type; - }; - - template - struct insert::value>::type> - { - typedef set type; - }; - - template class Predicate, typename T, typename Enable = void> - struct insert_if - { - typedef set type; - }; - - template class Predicate, typename T> - struct insert_if::value and Predicate::value>::type> - { - typedef set type; - }; - - }; - - template<> - struct make_set<> - { - typedef set<> type; - }; - - template - struct make_set - { - typedef typename make_set::type::template insert::type type; - }; - - template class Predicate, typename... T> - struct make_set_if; - - template class Predicate> - struct make_set_if - { - typedef set<> type; - }; - - template class Predicate, typename T, typename... Rest> - struct make_set_if - { - typedef typename make_set_if::type::template insert_if::type type; - }; - - template class Predicate, typename... T> - struct make_set_if_not - { - template - struct InversePredicate - { - static constexpr bool value = not Predicate::value; - }; - using type = typename make_set_if::type; - }; - - template - struct has_duplicates - : std::integral_constant::type::size::value != sizeof...(T)> {}; - - } -} - - -#endif diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h new file mode 100644 index 00000000..d367101f --- /dev/null +++ b/include/sqlpp11/detail/type_set.h @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2013, 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_SET_H +#define SQLPP_DETAIL_TYPE_SET_H + +#include +#include +#include + +namespace sqlpp +{ + namespace detail + { + // some forward declarations and helpers + template + struct make_set; + + template + class type_set_element {}; + + // A type set + template + struct type_set: type_set_element... + { + using size = std::integral_constant; + + template + using count = std::is_base_of, type_set>; + + template + struct is_superset_of + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_superset_of"); + }; + + template + struct is_superset_of> + : and_t {}; + + template + struct join + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for type_set::join"); + }; + + template + struct join> + : make_set {}; + + template + struct is_subset_of + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_subset_of"); + }; + + template + struct is_subset_of> + : type_set::template is_superset_of{}; + + template + struct is_disjunct_from + { + static_assert(::sqlpp::vendor::wrong_t::value, "invalid argument for is_disjunct_from"); + }; + + template + struct is_disjunct_from> + { + static constexpr bool value = not(or_t::value or or_t::template count, Element...>::value); + }; + + template + struct insert + { + using type = type_set; + }; + + template + struct insert::value>::type> + { + using type = type_set; + }; + + template class Predicate, typename T> + struct insert_if + { + using type = typename std::conditional::value, + type_set, + type_set>::type; + }; + }; + + template<> + struct make_set<> + { + using type = type_set<>; + }; + + template + struct make_set + { + using type = typename make_set::type::template insert::type; + }; + + template class Predicate, typename... T> + struct make_set_if; + + template class Predicate> + struct make_set_if + { + using type = type_set<>; + }; + + template class Predicate, typename T, typename... Rest> + struct make_set_if + { + using type = typename make_set_if::type::template insert_if::type; + }; + + template class Predicate, typename... T> + struct make_set_if_not + { + template + using InversePredicate = std::integral_constant::value>; + using type = typename make_set_if::type; + }; + + template + using has_duplicates = std::integral_constant::type::size::value != sizeof...(T)>; + + } +} + + +#endif diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index b8d9fdf5..918b3892 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -30,9 +30,11 @@ #include #include #include +#include #include #include #include +#include #include namespace sqlpp diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index 4d9cbc38..8cf50469 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -27,8 +27,9 @@ #ifndef SQLPP_MULTI_COLUMN_H #define SQLPP_MULTI_COLUMN_H -#include #include +#include +#include namespace sqlpp { @@ -41,8 +42,7 @@ namespace sqlpp template struct multi_column_t> { - using _named_expr_set = typename detail::make_set_if::type; - static_assert(_named_expr_set::size::value == sizeof...(NamedExpr), "multi_column parameters need to be named expressions"); + static_assert(detail::and_t::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 e628f33c..68c1297d 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -28,9 +28,9 @@ #define SQLPP_ON_H #include -#include #include #include +#include namespace sqlpp { @@ -41,8 +41,7 @@ namespace sqlpp using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; static_assert(_is_dynamic::value or sizeof...(Expr), "at least one expression argument required in on()"); - using _valid_expressions = typename detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not an expression in on()"); + static_assert(detail::and_t::value, "at least one argument is not an expression in on()"); template void add(E expr) diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index ffd15b30..3bcce768 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 0066889d..afa9f95e 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -41,7 +41,7 @@ namespace sqlpp template struct table_t: public table_base_t, public ColumnSpec::_name_t::template _member_t>... { - using _table_set = detail::set; // Hint need a set here to be similar to a join (which always represents more than one table) + using _table_set = detail::type_set
; // Hint need a type_set here to be similar to a join (which always represents more than one table) using _all_columns = typename detail::make_set...>::type; static_assert(_all_columns::size::value, "at least one column required per table"); using _required_insert_columns = typename detail::make_set_if...>::type; diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 2fa87c45..269d80b1 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -42,7 +42,7 @@ namespace sqlpp { //FIXME: Need to add join functionality using _is_table = std::true_type; - using _table_set = detail::set; + using _table_set = detail::type_set; struct _value_type: Table::_value_type { diff --git a/include/sqlpp11/vendor/column_list.h b/include/sqlpp11/vendor/column_list.h index 4659e1b2..e8bbdb9a 100644 --- a/include/sqlpp11/vendor/column_list.h +++ b/include/sqlpp11/vendor/column_list.h @@ -28,7 +28,7 @@ #define SQLPP_COLUMN_LIST_H #include -#include +#include #include #include @@ -49,12 +49,10 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in columns()"); // check for invalid columns - using _column_set = typename ::sqlpp::detail::make_set_if::type; - static_assert(_column_set::size::value == sizeof...(Columns), "at least one argument is not a column in columns()"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not a column in columns()"); // check for prohibited columns - using _prohibited_column_set = typename ::sqlpp::detail::make_set_if::type; - static_assert(_prohibited_column_set::size::value == 0, "at least one column argument has a must_not_insert flag in its definition"); + static_assert(not ::sqlpp::detail::or_t::value, "at least one column argument has a must_not_insert flag in its definition"); std::tuple...> _columns; }; diff --git a/include/sqlpp11/vendor/concat.h b/include/sqlpp11/vendor/concat.h index 0aa524b9..232e92d2 100644 --- a/include/sqlpp11/vendor/concat.h +++ b/include/sqlpp11/vendor/concat.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace sqlpp { @@ -39,8 +39,7 @@ namespace sqlpp struct concat_t: public First::_value_type::template operators> { static_assert(sizeof...(Args) > 0, "concat requires two arguments at least"); - using _valid_args = typename ::sqlpp::detail::make_set_if_not::type; - static_assert(_valid_args::size::value == 0, "at least one non-text argument detected in concat()"); + static_assert(sqlpp::detail::and_t::value, "at least one non-text argument detected in concat()"); struct _value_type: public First::_value_type::_base_value_type { diff --git a/include/sqlpp11/vendor/expression.h b/include/sqlpp11/vendor/expression.h index df1c3f56..20de7a16 100644 --- a/include/sqlpp11/vendor/expression.h +++ b/include/sqlpp11/vendor/expression.h @@ -164,10 +164,12 @@ namespace sqlpp template struct binary_expression_t: public O::_value_type::template operators> { + using _lhs_t = Lhs; + using _rhs_t = Rhs; using _value_type = typename O::_value_type; - using _parameter_tuple_t = std::tuple; + using _parameter_tuple_t = std::tuple<_lhs_t, _rhs_t>; - binary_expression_t(Lhs lhs, Rhs rhs): + binary_expression_t(_lhs_t lhs, _rhs_t rhs): _lhs(lhs), _rhs(rhs) {} @@ -178,8 +180,8 @@ namespace sqlpp binary_expression_t& operator=(binary_expression_t&&) = default; ~binary_expression_t() = default; - Lhs _lhs; - Rhs _rhs; + _lhs_t _lhs; + _rhs_t _rhs; }; template diff --git a/include/sqlpp11/vendor/from.h b/include/sqlpp11/vendor/from.h index da152d0d..11e8c999 100644 --- a/include/sqlpp11/vendor/from.h +++ b/include/sqlpp11/vendor/from.h @@ -27,11 +27,11 @@ #ifndef SQLPP_FROM_H #define SQLPP_FROM_H -#include #include #include #include #include +#include namespace sqlpp { @@ -50,8 +50,7 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in from()"); // check for invalid arguments - using _valid_expressions = typename ::sqlpp::detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(TableOrJoin), "at least one argument is not a table or join in from()"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not a table or join in from()"); // FIXME: Joins contain two tables. This is not being dealt with at the moment when looking at duplicates, for instance diff --git a/include/sqlpp11/vendor/group_by.h b/include/sqlpp11/vendor/group_by.h index db3e5d82..ca8e2e5e 100644 --- a/include/sqlpp11/vendor/group_by.h +++ b/include/sqlpp11/vendor/group_by.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -52,8 +52,7 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in group_by()"); // check for invalid expressions - using _valid_expressions = typename ::sqlpp::detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not an expression in group_by()"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not an expression in group_by()"); template void add(E expr) diff --git a/include/sqlpp11/vendor/having.h b/include/sqlpp11/vendor/having.h index 47fbc7cd..e9a474df 100644 --- a/include/sqlpp11/vendor/having.h +++ b/include/sqlpp11/vendor/having.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -45,8 +45,7 @@ namespace sqlpp using _parameter_tuple_t = std::tuple; static_assert(_is_dynamic::value or sizeof...(Expr), "at least one expression argument required in having()"); - using _valid_expressions = typename ::sqlpp::detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not an expression in having()"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not an expression in having()"); using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type; diff --git a/include/sqlpp11/vendor/in.h b/include/sqlpp11/vendor/in.h index c3e20b25..993a3288 100644 --- a/include/sqlpp11/vendor/in.h +++ b/include/sqlpp11/vendor/in.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/insert_list.h b/include/sqlpp11/vendor/insert_list.h index db3af25e..2d30390f 100644 --- a/include/sqlpp11/vendor/insert_list.h +++ b/include/sqlpp11/vendor/insert_list.h @@ -28,10 +28,10 @@ #define SQLPP_INSERT_LIST_H #include -#include #include #include #include +#include namespace sqlpp { @@ -61,6 +61,10 @@ namespace sqlpp using _is_insert_list = std::true_type; using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; using _parameter_tuple_t = std::tuple; + template class Target> + using copy_assignments_t = Target; // FIXME: Nice idea to copy variadic template arguments? + template class Target, template class Wrap> + using copy_wrapped_assignments_t = Target...>; // check for at least one order expression static_assert(_is_dynamic::value or sizeof...(Assignments), "at least one select expression required in set()"); @@ -69,14 +73,13 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in set()"); // check for invalid assignments - using _assignment_set = typename ::sqlpp::detail::make_set_if::type; - static_assert(_assignment_set::size::value == sizeof...(Assignments), "at least one argument is not an assignment in set()"); + static_assert(sqlpp::detail::and_t::value, "at least one argument is not an assignment in set()"); // check for prohibited assignments - using _prohibited_assignment_set = typename ::sqlpp::detail::make_set_if::type; - static_assert(_prohibited_assignment_set::size::value == 0, "at least one assignment is prohibited by its column definition in set()"); + static_assert(not sqlpp::detail::or_t::value, "at least one assignment is prohibited by its column definition in set()"); insert_list_t(Assignments... assignment): + _assignments(assignment...), _columns({assignment._lhs}...), _values(assignment._rhs...) {} @@ -99,6 +102,7 @@ namespace sqlpp std::tuple...> _columns; std::tuple _values; + std::tuple _assignments; // FIXME: Need to replace _columns and _values by _assignments (connector-container requires assignments) typename vendor::interpretable_list_t _dynamic_columns; typename vendor::interpretable_list_t _dynamic_values; }; diff --git a/include/sqlpp11/vendor/insert_value_list.h b/include/sqlpp11/vendor/insert_value_list.h index f3d2b4ba..76fc1552 100644 --- a/include/sqlpp11/vendor/insert_value_list.h +++ b/include/sqlpp11/vendor/insert_value_list.h @@ -28,7 +28,7 @@ #define SQLPP_INSERT_VALUE_LIST_H #include -#include +#include #include #include @@ -44,8 +44,7 @@ namespace sqlpp static_assert(sizeof...(InsertValues), "at least one insert value required"); // check for invalid arguments - using _insert_values_set = typename ::sqlpp::detail::make_set_if::type; - static_assert(_insert_values_set::size::value == sizeof...(InsertValues), "at least one argument is not an insert value"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not an insert value"); using _value_tuple_t = std::tuple; diff --git a/include/sqlpp11/vendor/is_null.h b/include/sqlpp11/vendor/is_null.h index 1bbafb64..7b7dab61 100644 --- a/include/sqlpp11/vendor/is_null.h +++ b/include/sqlpp11/vendor/is_null.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/like.h b/include/sqlpp11/vendor/like.h index 8647cb08..6ad5d9a9 100644 --- a/include/sqlpp11/vendor/like.h +++ b/include/sqlpp11/vendor/like.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/vendor/order_by.h b/include/sqlpp11/vendor/order_by.h index 34ee6c1d..fd58485f 100644 --- a/include/sqlpp11/vendor/order_by.h +++ b/include/sqlpp11/vendor/order_by.h @@ -51,8 +51,7 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in order_by()"); // check for invalid order expressions - using _valid_expressions = typename ::sqlpp::detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not a sort order expression in order_by()"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not a sort order expression in order_by()"); template void add(E expr) diff --git a/include/sqlpp11/vendor/select_column_list.h b/include/sqlpp11/vendor/select_column_list.h index 82d28111..ce421e8f 100644 --- a/include/sqlpp11/vendor/select_column_list.h +++ b/include/sqlpp11/vendor/select_column_list.h @@ -31,13 +31,13 @@ #include #include #include -#include #include #include +#include #include #include #include -#include +#include namespace sqlpp { @@ -149,9 +149,8 @@ namespace sqlpp // check for invalid select expressions template - struct is_valid_expression_t: public std::integral_constant::value or is_multi_column_t::value> {}; - using _valid_expressions = typename ::sqlpp::detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(NamedExpr), "at least one argument is not a named expression"); + using is_valid_expression_t = std::integral_constant::value or is_multi_column_t::value>; + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not a named expression"); // check for duplicate select expression names static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate name detected"); diff --git a/include/sqlpp11/vendor/select_flag_list.h b/include/sqlpp11/vendor/select_flag_list.h index 7833bef1..a167e4fc 100644 --- a/include/sqlpp11/vendor/select_flag_list.h +++ b/include/sqlpp11/vendor/select_flag_list.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -57,8 +57,7 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in select flag list"); // check for invalid order expressions - using _valid_flags = typename ::sqlpp::detail::make_set_if::type; - static_assert(_valid_flags::size::value == sizeof...(Flag), "at least one argument is not a select flag in select flag list"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not a select flag in select flag list"); template void add(E expr) diff --git a/include/sqlpp11/vendor/update_list.h b/include/sqlpp11/vendor/update_list.h index 435a2d83..a58e92fd 100644 --- a/include/sqlpp11/vendor/update_list.h +++ b/include/sqlpp11/vendor/update_list.h @@ -28,7 +28,7 @@ #define SQLPP_UPDATE_LIST_H #include -#include +#include #include #include @@ -50,12 +50,10 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in set()"); // check for invalid assignments - using _assignment_set = typename ::sqlpp::detail::make_set_if::type; - static_assert(_assignment_set::size::value == sizeof...(Assignments), "at least one argument is not an assignment in set()"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not an assignment in set()"); // check for prohibited assignments - using _prohibited_assignment_set = typename ::sqlpp::detail::make_set_if::type; - static_assert(_prohibited_assignment_set::size::value == 0, "at least one assignment is prohibited by its column definition in set()"); + static_assert(not ::sqlpp::detail::or_t::value, "at least one assignment is prohibited by its column definition in set()"); template void add(Assignment assignment) diff --git a/include/sqlpp11/vendor/using.h b/include/sqlpp11/vendor/using.h index 410a2cfe..7f98b821 100644 --- a/include/sqlpp11/vendor/using.h +++ b/include/sqlpp11/vendor/using.h @@ -28,9 +28,9 @@ #define SQLPP_USING_H #include -#include #include #include +#include namespace sqlpp { @@ -49,8 +49,7 @@ namespace sqlpp static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in using()"); // check for invalid arguments - using _valid_expressions = typename ::sqlpp::detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(Table), "at least one argument is not an table in using()"); + static_assert(::sqlpp::detail::and_t::value, "at least one argument is not an table in using()"); template diff --git a/include/sqlpp11/vendor/where.h b/include/sqlpp11/vendor/where.h index e4e87505..72de65fa 100644 --- a/include/sqlpp11/vendor/where.h +++ b/include/sqlpp11/vendor/where.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -48,8 +48,7 @@ namespace sqlpp using _parameter_tuple_t = std::tuple; static_assert(_is_dynamic::value or sizeof...(Expr), "at least one expression argument required in where()"); - using _valid_expressions = typename sqlpp::detail::make_set_if::type; - static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not an expression in where()"); + static_assert(sqlpp::detail::and_t::value, "at least one argument is not an expression in where()"); using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b9798885..b2a56c15 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,8 +14,10 @@ build_and_run(SelectTest) build_and_run(FunctionTest) build_and_run(PreparedTest) +find_package(PythonInterp REQUIRED) + add_custom_command( OUTPUT ${CMAKE_CURRENT_LIST_DIR}/Sample.h - COMMAND ${CMAKE_SOURCE_DIR}/scripts/ddl2cpp ${CMAKE_CURRENT_LIST_DIR}/sample.sql Sample test + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/ddl2cpp ${CMAKE_CURRENT_LIST_DIR}/sample.sql Sample test )