diff --git a/include/sqlpp11/chrono.h b/include/sqlpp11/chrono.h index 1ab77523..ab91d746 100644 --- a/include/sqlpp11/chrono.h +++ b/include/sqlpp11/chrono.h @@ -44,6 +44,14 @@ namespace sqlpp #else using ::date::floor; #endif + + + template + std::chrono::microseconds time_of_day(T t) + { + const auto dp = floor(t); + return std::chrono::duration_cast(::date::make_time(t - dp).to_duration()); + } } } diff --git a/include/sqlpp11/data_types.h b/include/sqlpp11/data_types.h index 0c54cc61..eee711bc 100644 --- a/include/sqlpp11/data_types.h +++ b/include/sqlpp11/data_types.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/include/sqlpp11/data_types/integral/wrap_operand.h b/include/sqlpp11/data_types/integral/wrap_operand.h index a395b864..1a07838a 100644 --- a/include/sqlpp11/data_types/integral/wrap_operand.h +++ b/include/sqlpp11/data_types/integral/wrap_operand.h @@ -35,7 +35,7 @@ namespace sqlpp struct integral_operand; template - struct wrap_operand::value and not std::is_same::value>::type> + struct wrap_operand::value and not std::is_same::value and not std::is_unsigned::value>::type> { using type = integral_operand; }; diff --git a/include/sqlpp11/data_types/unsigned_integral.h b/include/sqlpp11/data_types/unsigned_integral.h new file mode 100644 index 00000000..ba0a98ff --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_H +#define SQLPP_UNSIGNED_INTEGRAL_H + +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/sqlpp11/data_types/unsigned_integral/column_operators.h b/include/sqlpp11/data_types/unsigned_integral/column_operators.h new file mode 100644 index 00000000..ea98038b --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral/column_operators.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_COLUMN_OPERATORS_H +#define SQLPP_UNSIGNED_INTEGRAL_COLUMN_OPERATORS_H + +#include +#include +#include +#include +#include + +namespace sqlpp +{ + template + struct column_operators + { + template + using _is_valid_operand = is_valid_operand; + + template + auto operator+=(T t) const -> assignment_t, wrap_operand_t>> + { + using rhs = wrap_operand_t; + static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); + + return {*static_cast(this), {{*static_cast(this), rhs{t}}}}; + } + + template + auto operator-=(T t) const -> assignment_t, wrap_operand_t>> + { + using rhs = wrap_operand_t; + static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); + + return {*static_cast(this), {{*static_cast(this), rhs{t}}}}; + } + + template + auto operator/=(T t) const -> assignment_t>> + { + using rhs = wrap_operand_t; + static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); + + return {*static_cast(this), {{*static_cast(this), rhs{t}}}}; + } + + template + auto operator*=(T t) const -> assignment_t, wrap_operand_t>> + { + using rhs = wrap_operand_t; + static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); + + return {*static_cast(this), {{*static_cast(this), rhs{t}}}}; + } + }; +} + +#endif diff --git a/include/sqlpp11/data_types/unsigned_integral/data_type.h b/include/sqlpp11/data_types/unsigned_integral/data_type.h new file mode 100644 index 00000000..68e061aa --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral/data_type.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_DATA_TYPE_H +#define SQLPP_UNSIGNED_INTEGRAL_DATA_TYPE_H + +#include + +namespace sqlpp +{ + struct unsigned_integral + { + using _traits = make_traits; + using _cpp_value_type = uint64_t; + + template + using _is_valid_operand = is_numeric_t; + }; + + using tinyint_unsigned = unsigned_integral; + using smallint_unsigned = unsigned_integral; + using integer_unsigned = unsigned_integral; + using bigint_unsigned = unsigned_integral; +} +#endif diff --git a/include/sqlpp11/data_types/unsigned_integral/expression_operators.h b/include/sqlpp11/data_types/unsigned_integral/expression_operators.h new file mode 100644 index 00000000..0ce3b0e1 --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral/expression_operators.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_EXPRESSION_OPERATORS_H +#define SQLPP_UNSIGNED_INTEGRAL_EXPRESSION_OPERATORS_H + +#include +#include +#include +#include +#include +#include +#include + +namespace sqlpp +{ + template + struct expression_operators : public basic_expression_operators + { + }; + + template + struct return_type_plus> + { + using check = consistent_t; + using type = plus_t, value_type_of>, wrap_operand_t>; + }; + + template + struct return_type_minus> + { + using check = consistent_t; + using type = minus_t, value_type_of>, wrap_operand_t>; + }; + + template + struct return_type_multiplies> + { + using check = consistent_t; + using type = multiplies_t, value_type_of>, wrap_operand_t>; + }; + + template + struct return_type_divides> + { + using check = consistent_t; + using type = divides_t, wrap_operand_t>; + }; + + template + struct return_type_modulus> + { + using check = consistent_t; + using type = modulus_t, wrap_operand_t>; + }; + + template + struct return_type_unary_plus> + { + using check = consistent_t; + using type = unary_plus_t>; + }; + + template + struct return_type_unary_minus> + { + using check = consistent_t; + using type = unary_minus_t>; + }; + + template + struct return_type_bitwise_and> + { + using check = consistent_t; + using type = bitwise_and_t, unsigned_integral, wrap_operand_t>; + }; + + template + struct return_type_bitwise_or> + { + using check = consistent_t; + using type = bitwise_or_t, unsigned_integral, wrap_operand_t>; + }; +} +#endif diff --git a/include/sqlpp11/data_types/unsigned_integral/operand.h b/include/sqlpp11/data_types/unsigned_integral/operand.h new file mode 100644 index 00000000..d117b6fa --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral/operand.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_OPERAND_H +#define SQLPP_UNSIGNED_INTEGRAL_OPERAND_H + +#include +#include +#include + +namespace sqlpp +{ + struct unsigned_integral; + + struct unsigned_integral_operand : public alias_operators + { + using _traits = make_traits; + using _nodes = detail::type_vector<>; + using _is_aggregate_expression = std::true_type; + + using _value_t = uint64_t; + + unsigned_integral_operand() : _t{} + { + } + + unsigned_integral_operand(_value_t t) : _t(t) + { + } + + unsigned_integral_operand(const unsigned_integral_operand&) = default; + unsigned_integral_operand(unsigned_integral_operand&&) = default; + unsigned_integral_operand& operator=(const unsigned_integral_operand&) = default; + unsigned_integral_operand& operator=(unsigned_integral_operand&&) = default; + ~unsigned_integral_operand() = default; + + bool _is_trivial() const + { + return _t == 0; + } + + _value_t _t; + }; + + template + struct serializer_t + { + using _serialize_check = consistent_t; + using Operand = unsigned_integral_operand; + + static Context& _(const Operand& t, Context& context) + { + context << t._t; + return context; + } + }; +} + +#endif diff --git a/include/sqlpp11/data_types/unsigned_integral/parameter_value.h b/include/sqlpp11/data_types/unsigned_integral/parameter_value.h new file mode 100644 index 00000000..9b596d33 --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral/parameter_value.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_PARAMETER_VALUE_H +#define SQLPP_UNSIGNED_INTEGRAL_PARAMETER_VALUE_H + +#include +#include +#include +#include + +namespace sqlpp +{ + template <> + struct parameter_value_t : public parameter_value_base + { + using base = parameter_value_base; + using base::base; + using base::operator=; + + template + void _bind(Target& target, size_t index) const + { + target._bind_unsigned_integral_parameter(index, &_value, _is_null); + } + }; +} +#endif diff --git a/include/sqlpp11/data_types/unsigned_integral/result_field.h b/include/sqlpp11/data_types/unsigned_integral/result_field.h new file mode 100644 index 00000000..960ccc1a --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral/result_field.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_RESULT_FIELD_H +#define SQLPP_UNSIGNED_INTEGRAL_RESULT_FIELD_H + +#include +#include +#include +#include +#include + +namespace sqlpp +{ + template + struct result_field_t> + : public result_field_base> + { + template + void _bind(Target& target, size_t index) + { + target._bind_unsigned_integral_result(index, &this->_value, &this->_is_null); + } + + template + void _post_bind(Target& target, size_t index) + { + target._post_bind_unsigned_integral_result(index, &this->_value, &this->_is_null); + } + }; +} +#endif diff --git a/include/sqlpp11/data_types/unsigned_integral/wrap_operand.h b/include/sqlpp11/data_types/unsigned_integral/wrap_operand.h new file mode 100644 index 00000000..d12a5af6 --- /dev/null +++ b/include/sqlpp11/data_types/unsigned_integral/wrap_operand.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2013-2015, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_UNSIGNED_INTEGRAL_WRAP_OPERAND_H +#define SQLPP_UNSIGNED_INTEGRAL_WRAP_OPERAND_H + +#include +#include + +namespace sqlpp +{ + struct unsigned_integral_operand; + + template + struct wrap_operand::value and not std::is_same::value and std::is_unsigned::value>::type> + { + using type = unsigned_integral_operand; + }; +} +#endif diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 1b2d33ea..08a3f9fe 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -79,6 +79,10 @@ namespace sqlpp template using is_integral_t = std::is_same, integral>; + struct unsigned_integral; + template + using is_unsigned_integral_t = std::is_same, unsigned_integral>; + struct text; template using is_text_t = std::is_same, text>; @@ -89,7 +93,7 @@ namespace sqlpp // joined data type template - using is_numeric_t = logic::any_t::value, is_floating_point_t::value>; + using is_numeric_t = logic::any_t::value, is_unsigned_integral_t::value, is_floating_point_t::value>; template using is_day_or_time_point_t = logic::any_t::value, is_time_point_t::value>; diff --git a/tests/Sample.h b/tests/Sample.h index 0bb6dc51..bd9b30ea 100644 --- a/tests/Sample.h +++ b/tests/Sample.h @@ -75,9 +75,31 @@ namespace test }; using _traits = sqlpp::make_traits; }; + struct Psi + { + struct _alias_t + { + static constexpr const char _literal[] = "psi"; + using _name_t = sqlpp::make_char_sequence; + template + struct _member_t + { + T psi; + T& operator()() + { + return psi; + } + const T& operator()() const + { + return psi; + } + }; + }; + using _traits = sqlpp::make_traits; + }; } - struct TabFoo : sqlpp::table_t + struct TabFoo : sqlpp::table_t { struct _alias_t { diff --git a/tests/SelectType.cpp b/tests/SelectType.cpp index 712491e0..ce5bd2d8 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -108,6 +108,7 @@ int SelectType(int, char* []) using T = decltype(t.alpha); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_integral_t::value, "type requirement"); + static_assert(not sqlpp::is_unsigned_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); static_assert(sqlpp::is_expression_t::value, "type requirement"); static_assert(sqlpp::is_selectable_t::value, "type requirement"); @@ -121,6 +122,23 @@ int SelectType(int, char* []) static_assert(sqlpp::is_regular::value, "type requirement"); } + // Test an unsigned integral table column + { + using T = decltype(f.psi); + static_assert(sqlpp::is_numeric_t::value, "type requirement"); + static_assert(not sqlpp::is_integral_t::value, "type requirement"); + static_assert(sqlpp::is_unsigned_integral_t::value, "type requirement"); + static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); + static_assert(sqlpp::is_expression_t::value, "type requirement"); + static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(not sqlpp::require_insert_t::value, "type requirement"); + static_assert(not sqlpp::is_boolean_t::value, "type requirement"); + static_assert(not sqlpp::is_text_t::value, "type requirement"); + static_assert(not sqlpp::is_alias_t::value, "type requirement"); + static_assert(not sqlpp::is_table_t::value, "type requirement"); + static_assert(sqlpp::is_regular::value, "type requirement"); + } + // Test a floating point table column { using T = decltype(f.omega); diff --git a/tests/sample.sql b/tests/sample.sql index fc420fd0..5ebabf00 100644 --- a/tests/sample.sql +++ b/tests/sample.sql @@ -28,7 +28,8 @@ CREATE TABLE tab_foo ( delta varchar(255), epsilon bigint, - omega double + omega double, + psi bigint UNSIGNED ); CREATE TABLE tab_bar