From 44ce0338457524824c3c74458d4a8a30e055e2c7 Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Sun, 28 Jul 2024 20:49:19 +0200 Subject: [PATCH] Move more stuff --- .../sqlpp11/{ => aggregate_function}/over.h | 0 .../sqlpp11/aggregate_function_operators.h | 2 +- include/sqlpp11/{ => basic}/column.h | 2 +- include/sqlpp11/{ => basic}/column_fwd.h | 0 include/sqlpp11/{ => basic}/join.h | 6 +- include/sqlpp11/{ => basic}/join_types.h | 0 include/sqlpp11/{ => basic}/on.h | 0 include/sqlpp11/{ => basic}/pre_join.h | 6 +- include/sqlpp11/{ => basic}/table.h | 6 +- include/sqlpp11/{ => basic}/table_alias.h | 4 +- include/sqlpp11/{ => basic}/table_columns.h | 2 +- include/sqlpp11/{ => basic}/table_ref.h | 0 include/sqlpp11/{ => basic}/value.h | 0 include/sqlpp11/{ => clause}/cte.h | 2 +- include/sqlpp11/clause/from.h | 2 +- include/sqlpp11/clause/having.h | 2 +- include/sqlpp11/clause/insert_value.h | 2 +- include/sqlpp11/clause/insert_value_list.h | 2 +- include/sqlpp11/clause/select_column_list.h | 2 +- include/sqlpp11/clause/union.h | 197 ++++++++++++++++++ include/sqlpp11/{ => clause}/union_data.h | 0 include/sqlpp11/{ => clause}/union_flags.h | 0 include/sqlpp11/clause/where.h | 2 +- include/sqlpp11/clause/with.h | 2 +- include/sqlpp11/enable_join.h | 2 +- include/sqlpp11/enable_over.h | 2 +- include/sqlpp11/function.h | 2 +- .../{column_types.h => function/lower.h} | 47 ++++- include/sqlpp11/function/trim.h | 80 +++++++ include/sqlpp11/function/upper.h | 72 +++++++ include/sqlpp11/operator/assign_expression.h | 2 +- .../postgresql/returning_column_list.h | 2 +- include/sqlpp11/schema_qualified_table.h | 4 +- include/sqlpp11/sqlite3/serializer.h | 2 +- tests/core/static_asserts/AssertTables.h | 2 +- tests/core/usage/Sample.h | 4 +- tests/include/TabDepartment.h | 2 +- tests/mysql/serialize/Float.cpp | 2 +- tests/mysql/usage/Tables.h | 2 +- tests/postgresql/serialize/Float.cpp | 2 +- tests/postgresql/usage/Tables.h | 2 +- tests/sqlite3/serialize/Float.cpp | 2 +- tests/sqlite3/usage/Tables.h | 2 +- 43 files changed, 434 insertions(+), 42 deletions(-) rename include/sqlpp11/{ => aggregate_function}/over.h (100%) rename include/sqlpp11/{ => basic}/column.h (99%) rename include/sqlpp11/{ => basic}/column_fwd.h (100%) rename include/sqlpp11/{ => basic}/join.h (96%) rename include/sqlpp11/{ => basic}/join_types.h (100%) rename include/sqlpp11/{ => basic}/on.h (100%) rename include/sqlpp11/{ => basic}/pre_join.h (98%) rename include/sqlpp11/{ => basic}/table.h (96%) rename include/sqlpp11/{ => basic}/table_alias.h (97%) rename include/sqlpp11/{ => basic}/table_columns.h (97%) rename include/sqlpp11/{ => basic}/table_ref.h (100%) rename include/sqlpp11/{ => basic}/value.h (100%) rename include/sqlpp11/{ => clause}/cte.h (99%) create mode 100644 include/sqlpp11/clause/union.h rename include/sqlpp11/{ => clause}/union_data.h (100%) rename include/sqlpp11/{ => clause}/union_flags.h (100%) rename include/sqlpp11/{column_types.h => function/lower.h} (56%) create mode 100644 include/sqlpp11/function/trim.h create mode 100644 include/sqlpp11/function/upper.h diff --git a/include/sqlpp11/over.h b/include/sqlpp11/aggregate_function/over.h similarity index 100% rename from include/sqlpp11/over.h rename to include/sqlpp11/aggregate_function/over.h diff --git a/include/sqlpp11/aggregate_function_operators.h b/include/sqlpp11/aggregate_function_operators.h index 3cbecdf4..9c7f7a2a 100644 --- a/include/sqlpp11/aggregate_function_operators.h +++ b/include/sqlpp11/aggregate_function_operators.h @@ -26,7 +26,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/column.h b/include/sqlpp11/basic/column.h similarity index 99% rename from include/sqlpp11/column.h rename to include/sqlpp11/basic/column.h index 08c5e605..aa11a0f7 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/basic/column.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/sqlpp11/column_fwd.h b/include/sqlpp11/basic/column_fwd.h similarity index 100% rename from include/sqlpp11/column_fwd.h rename to include/sqlpp11/basic/column_fwd.h diff --git a/include/sqlpp11/join.h b/include/sqlpp11/basic/join.h similarity index 96% rename from include/sqlpp11/join.h rename to include/sqlpp11/basic/join.h index 5e5299b5..3eccf4b2 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/basic/join.h @@ -26,9 +26,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#include +#include +#include namespace sqlpp { diff --git a/include/sqlpp11/join_types.h b/include/sqlpp11/basic/join_types.h similarity index 100% rename from include/sqlpp11/join_types.h rename to include/sqlpp11/basic/join_types.h diff --git a/include/sqlpp11/on.h b/include/sqlpp11/basic/on.h similarity index 100% rename from include/sqlpp11/on.h rename to include/sqlpp11/basic/on.h diff --git a/include/sqlpp11/pre_join.h b/include/sqlpp11/basic/pre_join.h similarity index 98% rename from include/sqlpp11/pre_join.h rename to include/sqlpp11/basic/pre_join.h index 08e83806..fe30b208 100644 --- a/include/sqlpp11/pre_join.h +++ b/include/sqlpp11/basic/pre_join.h @@ -26,10 +26,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include -#include -#include +#include +#include namespace sqlpp { diff --git a/include/sqlpp11/table.h b/include/sqlpp11/basic/table.h similarity index 96% rename from include/sqlpp11/table.h rename to include/sqlpp11/basic/table.h index 06164f5f..b2fadee4 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/basic/table.h @@ -28,11 +28,11 @@ #include #include -#include +#include #include -#include +#include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/basic/table_alias.h similarity index 97% rename from include/sqlpp11/table_alias.h rename to include/sqlpp11/basic/table_alias.h index 324de99e..d3843df0 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/basic/table_alias.h @@ -27,10 +27,10 @@ */ #include -#include +#include #include #include -#include +#include #include namespace sqlpp diff --git a/include/sqlpp11/table_columns.h b/include/sqlpp11/basic/table_columns.h similarity index 97% rename from include/sqlpp11/table_columns.h rename to include/sqlpp11/basic/table_columns.h index ab7624a3..f5026b03 100644 --- a/include/sqlpp11/table_columns.h +++ b/include/sqlpp11/basic/table_columns.h @@ -28,7 +28,7 @@ #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/table_ref.h b/include/sqlpp11/basic/table_ref.h similarity index 100% rename from include/sqlpp11/table_ref.h rename to include/sqlpp11/basic/table_ref.h diff --git a/include/sqlpp11/value.h b/include/sqlpp11/basic/value.h similarity index 100% rename from include/sqlpp11/value.h rename to include/sqlpp11/basic/value.h diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/clause/cte.h similarity index 99% rename from include/sqlpp11/cte.h rename to include/sqlpp11/clause/cte.h index 09337598..f72ae2ba 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/clause/cte.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include namespace sqlpp diff --git a/include/sqlpp11/clause/from.h b/include/sqlpp11/clause/from.h index 2cd390c3..ebbfa7cc 100644 --- a/include/sqlpp11/clause/from.h +++ b/include/sqlpp11/clause/from.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include namespace sqlpp diff --git a/include/sqlpp11/clause/having.h b/include/sqlpp11/clause/having.h index d940d70a..0dc8ca00 100644 --- a/include/sqlpp11/clause/having.h +++ b/include/sqlpp11/clause/having.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/clause/insert_value.h b/include/sqlpp11/clause/insert_value.h index b837ae5c..b815c079 100644 --- a/include/sqlpp11/clause/insert_value.h +++ b/include/sqlpp11/clause/insert_value.h @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include diff --git a/include/sqlpp11/clause/insert_value_list.h b/include/sqlpp11/clause/insert_value_list.h index 50528f9e..1a715eb7 100644 --- a/include/sqlpp11/clause/insert_value_list.h +++ b/include/sqlpp11/clause/insert_value_list.h @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include #include diff --git a/include/sqlpp11/clause/select_column_list.h b/include/sqlpp11/clause/select_column_list.h index d7dff79f..1e1d64d4 100644 --- a/include/sqlpp11/clause/select_column_list.h +++ b/include/sqlpp11/clause/select_column_list.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include namespace sqlpp diff --git a/include/sqlpp11/clause/union.h b/include/sqlpp11/clause/union.h new file mode 100644 index 00000000..9352abcf --- /dev/null +++ b/include/sqlpp11/clause/union.h @@ -0,0 +1,197 @@ +#pragma once + +/* + * Copyright (c) 2013-2016, 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 +#include +#include +#include +#include +#include +#include + +namespace sqlpp +{ + struct no_union_t; + + using blank_union_t = statement_t; + // 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 = Check; + }; + + template + struct union_statement_impl + { + using type = statement_t; + }; + + template + using union_statement_t = typename union_statement_impl::type; + + // UNION(EXPR) + template + struct union_t + { + using _traits = make_traits; + using _nodes = detail::type_vector; + + using _data_t = union_data_t; + + // Base template to be inherited by the statement + template + struct _base_t + { + _base_t(_data_t data) : _data{std::move(data)} + { + } + + _data_t _data; + + using _selected_columns_t = typename std::decay::type; + _selected_columns_t& get_selected_columns() + { + return _data._lhs.get_selected_columns(); + } + const _selected_columns_t& get_selected_columns() const + { + return _data._lhs.get_selected_columns(); + } + + using _consistency_check = detail::get_first_if; + }; + + template + using _result_methods_t = typename Lhs::template _result_methods_t; + }; + + SQLPP_PORTABLE_STATIC_ASSERT(assert_union_args_are_statements_t, "arguments for union() must be statements"); + template + struct check_union + { + using type = static_combined_check_t< + static_check_t::value...>::value, assert_union_args_are_statements_t>>; + }; + template + using check_union_t = typename check_union::type; + + // NO UNION YET + struct no_union_t + { + using _traits = make_traits; + using _nodes = detail::type_vector<>; + + // Data + using _data_t = no_data_t; + + template + struct _base_t + { + _base_t() = default; + _base_t(_data_t data) : _data{std::move(data)} + { + } + + _data_t _data; + + template + using _new_statement_t = union_statement_t; + + using _consistency_check = consistent_t; + + template + auto union_distinct(Rhs rhs) const + -> _new_statement_t, Rhs>, + 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 clause/union.has to be a complete select statement"); + static_assert(has_result_row_t>::value, + "left hand side argument of a clause/union.has to be a complete select statement or union"); + + using lhs_result_row_t = get_result_row_t>; + using rhs_result_row_t = get_result_row_t; + static_assert(is_result_compatible::value, + "both arguments in a clause/union.have to have the same result columns (type and name)"); + + return _union_impl(check_union_t, Rhs>{}, rhs); + } + + template + auto union_all(Rhs rhs) const -> _new_statement_t, Rhs>, + 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 clause/union.has to be a (complete) select statement"); + static_assert(has_result_row_t>::value, + "left hand side argument of a clause/union.has to be a (complete) select statement"); + + using lhs_result_row_t = get_result_row_t>; + using rhs_result_row_t = get_result_row_t; + static_assert(is_result_compatible::value, + "both arguments in a clause/union.have to have the same result columns (type and name)"); + + return _union_impl(check_union_t, Rhs>{}, rhs); + } + + private: + template + auto _union_impl(Check, Rhs rhs) const -> inconsistent; + + template + auto _union_impl(consistent_t /*unused*/, Rhs rhs) const + -> _new_statement_t, Rhs>> + { + return {blank_union_t{}, union_data_t, Rhs>{ + static_cast&>(*this), rhs}}; + } + }; + }; + + /* + template + auto union_all(T&& t) -> decltype(statement_t().union_all(std::forward(t))) + { + return statement_t().union_all(std::forward(t)); + } + + template + auto union_distinct(T&& t) -> decltype(statement_t().union_distinct(std::forward(t))) + { + return statement_t().union_distinct(std::forward(t)); + } + */ +} // namespace sqlpp diff --git a/include/sqlpp11/union_data.h b/include/sqlpp11/clause/union_data.h similarity index 100% rename from include/sqlpp11/union_data.h rename to include/sqlpp11/clause/union_data.h diff --git a/include/sqlpp11/union_flags.h b/include/sqlpp11/clause/union_flags.h similarity index 100% rename from include/sqlpp11/union_flags.h rename to include/sqlpp11/clause/union_flags.h diff --git a/include/sqlpp11/clause/where.h b/include/sqlpp11/clause/where.h index 7683ba88..5d5b762c 100644 --- a/include/sqlpp11/clause/where.h +++ b/include/sqlpp11/clause/where.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/clause/with.h b/include/sqlpp11/clause/with.h index 89efdb9f..c87c80d5 100644 --- a/include/sqlpp11/clause/with.h +++ b/include/sqlpp11/clause/with.h @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include #include diff --git a/include/sqlpp11/enable_join.h b/include/sqlpp11/enable_join.h index 9da33a41..d388e437 100644 --- a/include/sqlpp11/enable_join.h +++ b/include/sqlpp11/enable_join.h @@ -27,7 +27,7 @@ */ #include -#include +#include namespace sqlpp { diff --git a/include/sqlpp11/enable_over.h b/include/sqlpp11/enable_over.h index eac7b631..cdcbec6d 100644 --- a/include/sqlpp11/enable_over.h +++ b/include/sqlpp11/enable_over.h @@ -26,7 +26,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include namespace sqlpp diff --git a/include/sqlpp11/function.h b/include/sqlpp11/function.h index 98268aee..4459910e 100644 --- a/include/sqlpp11/function.h +++ b/include/sqlpp11/function.h @@ -39,7 +39,7 @@ #include // Csaba Csoma suggests: unsafe_sql instead of verbatim #include #include -#include +#include #include namespace sqlpp diff --git a/include/sqlpp11/column_types.h b/include/sqlpp11/function/lower.h similarity index 56% rename from include/sqlpp11/column_types.h rename to include/sqlpp11/function/lower.h index ccd7a130..4f30e177 100644 --- a/include/sqlpp11/column_types.h +++ b/include/sqlpp11/function/lower.h @@ -1,7 +1,7 @@ #pragma once /* - * Copyright (c) 2013-2015, Roland Bock + * Copyright (c) 2023, Roland Bock * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -26,4 +26,47 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include +#include + +namespace sqlpp +{ + template + struct lower_t + { + using _traits = make_traits; + + using _nodes = detail::type_vector; + + lower_t(const Expr expr) : _expr(expr) + { + } + + lower_t(const lower_t&) = default; + lower_t(lower_t&&) = default; + lower_t& operator=(const lower_t&) = default; + lower_t& operator=(lower_t&&) = default; + ~lower_t() = default; + + Expr _expr; + }; + + template + Context& serialize(Context& context, const lower_t& t) + { + context << "LOWER("; + serialize_operand(context, t._expr); + context << ")"; + return context; + } + + template + using check_lower_args = std::enable_if_t::value>; + + template > + auto lower(T t) -> lower_t + { + return {std::move(t)}; + } + +} // namespace sqlpp diff --git a/include/sqlpp11/function/trim.h b/include/sqlpp11/function/trim.h new file mode 100644 index 00000000..68087b6c --- /dev/null +++ b/include/sqlpp11/function/trim.h @@ -0,0 +1,80 @@ +#pragma once + +/* + * Copyright (c) 2013-2015, Roland Bock + * Copyright (c) 2017, Juan Dent + * 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 + +namespace sqlpp +{ + template + struct trim_t + { + using _traits = make_traits; + + trim_t(const Expr expr) : _expr(expr) + { + } + + trim_t(const trim_t&) = default; + trim_t(trim_t&&) = default; + trim_t& operator=(const trim_t&) = default; + trim_t& operator=(trim_t&&) = default; + ~trim_t() = default; + + Expr _expr; + }; + + template + struct value_type_of> : public value_type_of {}; + + template + struct nodes_of> + { + using type = detail::type_vector; + }; + + template + Context& serialize(Context& context, const trim_t& t) + { + context << "TRIM("; + serialize_operand(context, t._expr); + context << ")"; + return context; + } + + template + using check_trim_args = std::enable_if_t::value>; + + template > + auto trim(T t) -> trim_t + { + return {std::move(t)}; + } + +} // namespace sqlpp diff --git a/include/sqlpp11/function/upper.h b/include/sqlpp11/function/upper.h new file mode 100644 index 00000000..466e739b --- /dev/null +++ b/include/sqlpp11/function/upper.h @@ -0,0 +1,72 @@ +#pragma once + +/* + * Copyright (c) 2023, 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 + +namespace sqlpp +{ + template + struct upper_t + { + using _traits = make_traits; + + using _nodes = detail::type_vector; + + upper_t(const Expr expr) : _expr(expr) + { + } + + upper_t(const upper_t&) = default; + upper_t(upper_t&&) = default; + upper_t& operator=(const upper_t&) = default; + upper_t& operator=(upper_t&&) = default; + ~upper_t() = default; + + Expr _expr; + }; + + template + Context& serialize(Context& context, const upper_t& t) + { + context << "UPPER("; + serialize_operand(context, t._expr); + context << ")"; + return context; + } + + template + using check_upper_args = std::enable_if_t::value>; + + template > + auto upper(T t) -> upper_t + { + return {std::move(t)}; + } + +} // namespace sqlpp diff --git a/include/sqlpp11/operator/assign_expression.h b/include/sqlpp11/operator/assign_expression.h index 3d3ad089..e6bbd336 100644 --- a/include/sqlpp11/operator/assign_expression.h +++ b/include/sqlpp11/operator/assign_expression.h @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include +#include #include #include diff --git a/include/sqlpp11/postgresql/returning_column_list.h b/include/sqlpp11/postgresql/returning_column_list.h index e6e4b9de..4069b107 100644 --- a/include/sqlpp11/postgresql/returning_column_list.h +++ b/include/sqlpp11/postgresql/returning_column_list.h @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include namespace sqlpp diff --git a/include/sqlpp11/schema_qualified_table.h b/include/sqlpp11/schema_qualified_table.h index 09d561c6..3f7d08dd 100644 --- a/include/sqlpp11/schema_qualified_table.h +++ b/include/sqlpp11/schema_qualified_table.h @@ -26,11 +26,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include -#include +#include #include #include diff --git a/include/sqlpp11/sqlite3/serializer.h b/include/sqlpp11/sqlite3/serializer.h index d696529a..323bea62 100644 --- a/include/sqlpp11/sqlite3/serializer.h +++ b/include/sqlpp11/sqlite3/serializer.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/tests/core/static_asserts/AssertTables.h b/tests/core/static_asserts/AssertTables.h index bdc48bfc..60dc2078 100644 --- a/tests/core/static_asserts/AssertTables.h +++ b/tests/core/static_asserts/AssertTables.h @@ -2,7 +2,7 @@ // generated by ../scripts/ddl2cpp ../test_static_asserts/AssertTables.sql ../test_static_asserts/AssertTables test -#include +#include #include #include diff --git a/tests/core/usage/Sample.h b/tests/core/usage/Sample.h index 6e7225ac..e0164b5e 100644 --- a/tests/core/usage/Sample.h +++ b/tests/core/usage/Sample.h @@ -2,8 +2,8 @@ // generated by ./scripts/ddl2cpp -auto-id tests/core/usage/sample.sql tests/core/usage/Sample test -#include -#include +#include +#include #include #include diff --git a/tests/include/TabDepartment.h b/tests/include/TabDepartment.h index aed3dd4b..bf7ce315 100644 --- a/tests/include/TabDepartment.h +++ b/tests/include/TabDepartment.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/tests/mysql/serialize/Float.cpp b/tests/mysql/serialize/Float.cpp index d19ce39c..712bca38 100644 --- a/tests/mysql/serialize/Float.cpp +++ b/tests/mysql/serialize/Float.cpp @@ -24,7 +24,7 @@ */ #include -#include +#include #include "compare.h" diff --git a/tests/mysql/usage/Tables.h b/tests/mysql/usage/Tables.h index 87766208..99c1362a 100644 --- a/tests/mysql/usage/Tables.h +++ b/tests/mysql/usage/Tables.h @@ -2,7 +2,7 @@ // generated by ./scripts/ddl2cpp -auto-id -with-table-creation-helper tests/mysql/usage/Tables.sql tests/mysql/usage/Tables test -#include +#include #include #include diff --git a/tests/postgresql/serialize/Float.cpp b/tests/postgresql/serialize/Float.cpp index d19ce39c..712bca38 100644 --- a/tests/postgresql/serialize/Float.cpp +++ b/tests/postgresql/serialize/Float.cpp @@ -24,7 +24,7 @@ */ #include -#include +#include #include "compare.h" diff --git a/tests/postgresql/usage/Tables.h b/tests/postgresql/usage/Tables.h index d2ad11b6..eaccfae6 100644 --- a/tests/postgresql/usage/Tables.h +++ b/tests/postgresql/usage/Tables.h @@ -2,7 +2,7 @@ // generated by ./scripts/ddl2cpp -auto-id -with-table-creation-helper tests/postgresql/usage/Tables.sql tests/postgresql/usage/Tables test -#include +#include #include #include diff --git a/tests/sqlite3/serialize/Float.cpp b/tests/sqlite3/serialize/Float.cpp index d19ce39c..712bca38 100644 --- a/tests/sqlite3/serialize/Float.cpp +++ b/tests/sqlite3/serialize/Float.cpp @@ -24,7 +24,7 @@ */ #include -#include +#include #include "compare.h" diff --git a/tests/sqlite3/usage/Tables.h b/tests/sqlite3/usage/Tables.h index a161a780..ff4143af 100644 --- a/tests/sqlite3/usage/Tables.h +++ b/tests/sqlite3/usage/Tables.h @@ -2,7 +2,7 @@ // generated by ./scripts/ddl2cpp -auto-id -with-table-creation-helper tests/sqlite3/usage/Tables.sql tests/sqlite3/usage/Tables test -#include +#include #include #include