mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Move more stuff
This commit is contained in:
parent
df8e2b6c81
commit
44ce033845
@ -26,7 +26,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sqlpp11/over.h>
|
||||
#include <sqlpp11/aggregate_function/over.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <sqlpp11/enable_comparison.h>
|
||||
#include <sqlpp11/operator/as_expression.h>
|
||||
#include <sqlpp11/operator/assign_expression.h>
|
||||
#include <sqlpp11/column_fwd.h>
|
||||
#include <sqlpp11/basic/column_fwd.h>
|
||||
#include <sqlpp11/default_value.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/wrong.h>
|
@ -26,9 +26,9 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sqlpp11/join_types.h>
|
||||
#include <sqlpp11/pre_join.h>
|
||||
#include <sqlpp11/on.h>
|
||||
#include <sqlpp11/basic/join_types.h>
|
||||
#include <sqlpp11/basic/pre_join.h>
|
||||
#include <sqlpp11/basic/on.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
@ -26,10 +26,10 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sqlpp11/join_types.h>
|
||||
#include <sqlpp11/basic/join_types.h>
|
||||
#include <sqlpp11/noop.h>
|
||||
#include <sqlpp11/on.h>
|
||||
#include <sqlpp11/table_ref.h>
|
||||
#include <sqlpp11/basic/on.h>
|
||||
#include <sqlpp11/basic/table_ref.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
@ -28,11 +28,11 @@
|
||||
|
||||
#include <sqlpp11/enable_join.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/table_alias.h>
|
||||
#include <sqlpp11/basic/table_alias.h>
|
||||
#include <sqlpp11/all_of.h>
|
||||
#include <sqlpp11/column.h>
|
||||
#include <sqlpp11/basic/column.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
#include <sqlpp11/join.h>
|
||||
#include <sqlpp11/basic/join.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
@ -27,10 +27,10 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/enable_join.h>
|
||||
#include <sqlpp11/table_columns.h>
|
||||
#include <sqlpp11/basic/table_columns.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
#include <sqlpp11/serialize.h>
|
||||
#include <sqlpp11/join.h>
|
||||
#include <sqlpp11/basic/join.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include <sqlpp11/column_fwd.h>
|
||||
#include <sqlpp11/basic/column_fwd.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
@ -32,7 +32,7 @@
|
||||
#include <sqlpp11/result_row.h>
|
||||
#include <sqlpp11/clause/select_flags.h>
|
||||
#include <sqlpp11/statement_fwd.h>
|
||||
#include <sqlpp11/table_ref.h>
|
||||
#include <sqlpp11/basic/table_ref.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
@ -30,7 +30,7 @@
|
||||
#include <sqlpp11/logic.h>
|
||||
#include <sqlpp11/no_data.h>
|
||||
#include <sqlpp11/policy_update.h>
|
||||
#include <sqlpp11/table_ref.h>
|
||||
#include <sqlpp11/basic/table_ref.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <sqlpp11/logic.h>
|
||||
#include <sqlpp11/policy_update.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/value.h>
|
||||
#include <sqlpp11/basic/value.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/default_value.h>
|
||||
#include <sqlpp11/value.h>
|
||||
#include <sqlpp11/basic/value.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/operator/assign_expression.h>
|
||||
#include <sqlpp11/column_fwd.h>
|
||||
#include <sqlpp11/basic/column_fwd.h>
|
||||
#include <sqlpp11/clause/insert_value.h>
|
||||
#include <sqlpp11/interpret_tuple.h>
|
||||
#include <sqlpp11/logic.h>
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <sqlpp11/result_row.h>
|
||||
#include <sqlpp11/clause/select_as.h>
|
||||
#include <sqlpp11/clause/select_column_traits.h>
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <tuple>
|
||||
|
||||
namespace sqlpp
|
||||
|
197
include/sqlpp11/clause/union.h
Normal file
197
include/sqlpp11/clause/union.h
Normal file
@ -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 <sqlpp11/interpret_tuple.h>
|
||||
#include <sqlpp11/logic.h>
|
||||
#include <sqlpp11/parameter_list.h>
|
||||
#include <sqlpp11/result_row.h>
|
||||
#include <sqlpp11/statement_fwd.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/clause/union_data.h>
|
||||
#include <sqlpp11/clause/union_flags.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct no_union_t;
|
||||
|
||||
using blank_union_t = statement_t<no_union_t>;
|
||||
// There is no order by or limit or offset in union, use it as a pseudo table to do that.
|
||||
|
||||
template <typename Check, typename Union>
|
||||
struct union_statement_impl
|
||||
{
|
||||
using type = Check;
|
||||
};
|
||||
|
||||
template <typename Union>
|
||||
struct union_statement_impl<consistent_t, Union>
|
||||
{
|
||||
using type = statement_t<Union, no_union_t>;
|
||||
};
|
||||
|
||||
template <typename Check, typename Union>
|
||||
using union_statement_t = typename union_statement_impl<Check, Union>::type;
|
||||
|
||||
// UNION(EXPR)
|
||||
template <typename Flag, typename Lhs, typename Rhs>
|
||||
struct union_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::is_union, tag::is_return_value>;
|
||||
using _nodes = detail::type_vector<Lhs, Rhs>;
|
||||
|
||||
using _data_t = union_data_t<Flag, Lhs, Rhs>;
|
||||
|
||||
// Base template to be inherited by the statement
|
||||
template <typename Policies>
|
||||
struct _base_t
|
||||
{
|
||||
_base_t(_data_t data) : _data{std::move(data)}
|
||||
{
|
||||
}
|
||||
|
||||
_data_t _data;
|
||||
|
||||
using _selected_columns_t = typename std::decay<decltype(_data._lhs.get_selected_columns())>::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<is_inconsistent_t,
|
||||
consistent_t,
|
||||
typename Lhs::_consistency_check,
|
||||
typename Rhs::_consistency_check>;
|
||||
};
|
||||
|
||||
template <typename Statement>
|
||||
using _result_methods_t = typename Lhs::template _result_methods_t<Statement>;
|
||||
};
|
||||
|
||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_union_args_are_statements_t, "arguments for union() must be statements");
|
||||
template <typename... T>
|
||||
struct check_union
|
||||
{
|
||||
using type = static_combined_check_t<
|
||||
static_check_t<logic::all_t<is_statement_t<T>::value...>::value, assert_union_args_are_statements_t>>;
|
||||
};
|
||||
template <typename... T>
|
||||
using check_union_t = typename check_union<T...>::type;
|
||||
|
||||
// NO UNION YET
|
||||
struct no_union_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::is_union>;
|
||||
using _nodes = detail::type_vector<>;
|
||||
|
||||
// Data
|
||||
using _data_t = no_data_t;
|
||||
|
||||
template <typename Policies>
|
||||
struct _base_t
|
||||
{
|
||||
_base_t() = default;
|
||||
_base_t(_data_t data) : _data{std::move(data)}
|
||||
{
|
||||
}
|
||||
|
||||
_data_t _data;
|
||||
|
||||
template <typename Check, typename T>
|
||||
using _new_statement_t = union_statement_t<Check, T>;
|
||||
|
||||
using _consistency_check = consistent_t;
|
||||
|
||||
template <typename Rhs>
|
||||
auto union_distinct(Rhs rhs) const
|
||||
-> _new_statement_t<check_union_t<derived_statement_t<Policies>, Rhs>,
|
||||
union_t<union_distinct_t, derived_statement_t<Policies>, Rhs>>
|
||||
{
|
||||
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
|
||||
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
|
||||
static_assert(has_result_row_t<Rhs>::value, "argument of a clause/union.has to be a complete select statement");
|
||||
static_assert(has_result_row_t<derived_statement_t<Policies>>::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<derived_statement_t<Policies>>;
|
||||
using rhs_result_row_t = get_result_row_t<Rhs>;
|
||||
static_assert(is_result_compatible<lhs_result_row_t, rhs_result_row_t>::value,
|
||||
"both arguments in a clause/union.have to have the same result columns (type and name)");
|
||||
|
||||
return _union_impl<union_distinct_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
|
||||
}
|
||||
|
||||
template <typename Rhs>
|
||||
auto union_all(Rhs rhs) const -> _new_statement_t<check_union_t<derived_statement_t<Policies>, Rhs>,
|
||||
union_t<union_all_t, derived_statement_t<Policies>, Rhs>>
|
||||
{
|
||||
static_assert(is_statement_t<Rhs>::value, "argument of union call has to be a statement");
|
||||
static_assert(has_policy_t<Rhs, is_select_t>::value, "argument of union call has to be a select");
|
||||
static_assert(has_result_row_t<Rhs>::value, "argument of a clause/union.has to be a (complete) select statement");
|
||||
static_assert(has_result_row_t<derived_statement_t<Policies>>::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<derived_statement_t<Policies>>;
|
||||
using rhs_result_row_t = get_result_row_t<Rhs>;
|
||||
static_assert(is_result_compatible<lhs_result_row_t, rhs_result_row_t>::value,
|
||||
"both arguments in a clause/union.have to have the same result columns (type and name)");
|
||||
|
||||
return _union_impl<union_all_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Flag, typename Check, typename Rhs>
|
||||
auto _union_impl(Check, Rhs rhs) const -> inconsistent<Check>;
|
||||
|
||||
template <typename Flag, typename Rhs>
|
||||
auto _union_impl(consistent_t /*unused*/, Rhs rhs) const
|
||||
-> _new_statement_t<consistent_t, union_t<Flag, derived_statement_t<Policies>, Rhs>>
|
||||
{
|
||||
return {blank_union_t{}, union_data_t<Flag, derived_statement_t<Policies>, Rhs>{
|
||||
static_cast<const derived_statement_t<Policies>&>(*this), rhs}};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
template <typename T>
|
||||
auto union_all(T&& t) -> decltype(statement_t<no_union_t>().union_all(std::forward<T>(t)))
|
||||
{
|
||||
return statement_t<no_union_t>().union_all(std::forward<T>(t));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto union_distinct(T&& t) -> decltype(statement_t<no_union_t>().union_distinct(std::forward<T>(t)))
|
||||
{
|
||||
return statement_t<no_union_t>().union_distinct(std::forward<T>(t));
|
||||
}
|
||||
*/
|
||||
} // namespace sqlpp
|
@ -32,7 +32,7 @@
|
||||
#include <sqlpp11/statement_fwd.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/unconditional.h>
|
||||
#include <sqlpp11/value.h>
|
||||
#include <sqlpp11/basic/value.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/operator/assign_expression.h>
|
||||
#include <sqlpp11/column_fwd.h>
|
||||
#include <sqlpp11/basic/column_fwd.h>
|
||||
#include <sqlpp11/interpret_tuple.h>
|
||||
#include <sqlpp11/logic.h>
|
||||
#include <sqlpp11/no_data.h>
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/join.h>
|
||||
#include <sqlpp11/basic/join.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
|
@ -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 <sqlpp11/over.h>
|
||||
#include <sqlpp11/aggregate_function/over.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <sqlpp11/verbatim.h> // Csaba Csoma suggests: unsafe_sql instead of verbatim
|
||||
#include <sqlpp11/parameterized_verbatim.h>
|
||||
#include <sqlpp11/verbatim_table.h>
|
||||
#include <sqlpp11/value.h>
|
||||
#include <sqlpp11/basic/value.h>
|
||||
#include <sqlpp11/eval.h>
|
||||
|
||||
namespace sqlpp
|
||||
|
@ -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 <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/serialize.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expr>
|
||||
struct lower_t
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_expression, tag::is_selectable>;
|
||||
|
||||
using _nodes = detail::type_vector<Expr>;
|
||||
|
||||
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 <typename Context, typename Expr>
|
||||
Context& serialize(Context& context, const lower_t<Expr>& t)
|
||||
{
|
||||
context << "LOWER(";
|
||||
serialize_operand(context, t._expr);
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using check_lower_args = std::enable_if_t<is_text<T>::value>;
|
||||
|
||||
template <typename T, typename = check_lower_args<T>>
|
||||
auto lower(T t) -> lower_t<T>
|
||||
{
|
||||
return {std::move(t)};
|
||||
}
|
||||
|
||||
} // namespace sqlpp
|
80
include/sqlpp11/function/trim.h
Normal file
80
include/sqlpp11/function/trim.h
Normal file
@ -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 <sqlpp11/serialize.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expr>
|
||||
struct trim_t
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_expression, tag::is_selectable>;
|
||||
|
||||
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<typename Expr>
|
||||
struct value_type_of<trim_t<Expr>> : public value_type_of<Expr> {};
|
||||
|
||||
template<typename Expr>
|
||||
struct nodes_of<trim_t<Expr>>
|
||||
{
|
||||
using type = detail::type_vector<Expr>;
|
||||
};
|
||||
|
||||
template <typename Context, typename Expr>
|
||||
Context& serialize(Context& context, const trim_t<Expr>& t)
|
||||
{
|
||||
context << "TRIM(";
|
||||
serialize_operand(context, t._expr);
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using check_trim_args = std::enable_if_t<is_text<T>::value>;
|
||||
|
||||
template <typename T, typename = check_trim_args<T>>
|
||||
auto trim(T t) -> trim_t<T>
|
||||
{
|
||||
return {std::move(t)};
|
||||
}
|
||||
|
||||
} // namespace sqlpp
|
72
include/sqlpp11/function/upper.h
Normal file
72
include/sqlpp11/function/upper.h
Normal file
@ -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 <sqlpp11/serialize.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename Expr>
|
||||
struct upper_t
|
||||
{
|
||||
using _traits = make_traits<text, tag::is_expression, tag::is_selectable>;
|
||||
|
||||
using _nodes = detail::type_vector<Expr>;
|
||||
|
||||
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 <typename Context, typename Expr>
|
||||
Context& serialize(Context& context, const upper_t<Expr>& t)
|
||||
{
|
||||
context << "UPPER(";
|
||||
serialize_operand(context, t._expr);
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using check_upper_args = std::enable_if_t<is_text<T>::value>;
|
||||
|
||||
template <typename T, typename = check_upper_args<T>>
|
||||
auto upper(T t) -> upper_t<T>
|
||||
{
|
||||
return {std::move(t)};
|
||||
}
|
||||
|
||||
} // namespace sqlpp
|
@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <sqlpp11/column_fwd.h>
|
||||
#include <sqlpp11/basic/column_fwd.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/default_value.h>
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include <sqlpp11/policy_update.h>
|
||||
#include <sqlpp11/result_row.h>
|
||||
#include <sqlpp11/select_pseudo_table.h>
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <tuple>
|
||||
|
||||
namespace sqlpp
|
||||
|
@ -26,11 +26,11 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sqlpp11/column_fwd.h>
|
||||
#include <sqlpp11/basic/column_fwd.h>
|
||||
#include <sqlpp11/serialize.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/schema.h>
|
||||
#include <sqlpp11/table_alias.h>
|
||||
#include <sqlpp11/basic/table_alias.h>
|
||||
#include <sqlpp11/detail/type_set.h>
|
||||
|
||||
#include <utility>
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <sqlpp11/data_types/time_point/operand.h>
|
||||
#include <sqlpp11/data_types/unsigned_integral/operand.h>
|
||||
#include <sqlpp11/parameter.h>
|
||||
#include <sqlpp11/pre_join.h>
|
||||
#include <sqlpp11/basic/pre_join.h>
|
||||
#include <sqlpp11/some.h>
|
||||
#include <sqlpp11/clause/with.h>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
// generated by ../scripts/ddl2cpp ../test_static_asserts/AssertTables.sql ../test_static_asserts/AssertTables test
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
// generated by ./scripts/ddl2cpp -auto-id tests/core/usage/sample.sql tests/core/usage/Sample test
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/table_columns.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <sqlpp11/basic/table_columns.h>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <sqlpp11/table.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/data_types/floating_point.h>
|
||||
#include <sqlpp11/value.h>
|
||||
#include <sqlpp11/basic/value.h>
|
||||
|
||||
#include "compare.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 <sqlpp11/table.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/data_types/floating_point.h>
|
||||
#include <sqlpp11/value.h>
|
||||
#include <sqlpp11/basic/value.h>
|
||||
|
||||
#include "compare.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 <sqlpp11/table.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <sqlpp11/data_types/floating_point.h>
|
||||
#include <sqlpp11/value.h>
|
||||
#include <sqlpp11/basic/value.h>
|
||||
|
||||
#include "compare.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 <sqlpp11/table.h>
|
||||
#include <sqlpp11/basic/table.h>
|
||||
#include <sqlpp11/data_types.h>
|
||||
#include <sqlpp11/char_sequence.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user