mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Merge branch 'release/0.55'
This commit is contained in:
commit
a643095958
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
CMakeLists.txt.user
|
||||||
|
@ -72,6 +72,11 @@ install(TARGETS sqlpp11
|
|||||||
EXPORT Sqlpp11Targets
|
EXPORT Sqlpp11Targets
|
||||||
)
|
)
|
||||||
|
|
||||||
|
install(PROGRAMS "${PROJECT_SOURCE_DIR}/scripts/ddl2cpp"
|
||||||
|
RENAME sqlpp11-ddl2cpp
|
||||||
|
DESTINATION bin
|
||||||
|
)
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
|
@ -29,3 +29,17 @@ include(CMakeFindDependencyMacro)
|
|||||||
find_dependency(HinnantDate REQUIRED)
|
find_dependency(HinnantDate REQUIRED)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/Sqlpp11Targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/Sqlpp11Targets.cmake")
|
||||||
|
|
||||||
|
# Import "ddl2cpp" script
|
||||||
|
if(TARGET sqlpp11::ddl2cpp)
|
||||||
|
message(FATAL_ERROR "Target sqlpp11::ddl2cpp already defined")
|
||||||
|
endif()
|
||||||
|
get_filename_component(sqlpp11_ddl2cpp_location "${CMAKE_CURRENT_LIST_DIR}/../../../bin/sqlpp11-ddl2cpp" REALPATH)
|
||||||
|
if(NOT EXISTS "${sqlpp11_ddl2cpp_location}")
|
||||||
|
message(FATAL_ERROR "The imported target sqlpp11::ddl2cpp references the file '${sqlpp11_ddl2cpp_location}' but this file does not exists.")
|
||||||
|
endif()
|
||||||
|
add_executable(sqlpp11::ddl2cpp IMPORTED)
|
||||||
|
set_target_properties(sqlpp11::ddl2cpp PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${sqlpp11_ddl2cpp_location}"
|
||||||
|
)
|
||||||
|
unset(sqlpp11_ddl2cpp_location)
|
||||||
|
@ -127,7 +127,7 @@ namespace sqlpp
|
|||||||
auto operator==(T t) const -> _new_binary_expression_t<equal_to_t, T>
|
auto operator==(T t) const -> _new_binary_expression_t<equal_to_t, T>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_comparison_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>{};
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ namespace sqlpp
|
|||||||
auto operator!=(T t) const -> _new_binary_expression_t<not_equal_to_t, T>
|
auto operator!=(T t) const -> _new_binary_expression_t<not_equal_to_t, T>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_comparison_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>{};
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ namespace sqlpp
|
|||||||
auto operator<(T t) const -> _new_binary_expression_t<less_than_t, T>
|
auto operator<(T t) const -> _new_binary_expression_t<less_than_t, T>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_comparison_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>{};
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ namespace sqlpp
|
|||||||
auto operator<=(T t) const -> _new_binary_expression_t<less_equal_t, T>
|
auto operator<=(T t) const -> _new_binary_expression_t<less_equal_t, T>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_comparison_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>{};
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ namespace sqlpp
|
|||||||
auto operator>(T t) const -> _new_binary_expression_t<greater_than_t, T>
|
auto operator>(T t) const -> _new_binary_expression_t<greater_than_t, T>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_comparison_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>{};
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ namespace sqlpp
|
|||||||
auto operator>=(T t) const -> _new_binary_expression_t<greater_equal_t, T>
|
auto operator>=(T t) const -> _new_binary_expression_t<greater_equal_t, T>
|
||||||
{
|
{
|
||||||
using rhs = wrap_operand_t<T>;
|
using rhs = wrap_operand_t<T>;
|
||||||
check_comparison_t<Expr, rhs>::_();
|
check_comparison_t<Expr, rhs>{};
|
||||||
|
|
||||||
return {*static_cast<const Expr*>(this), rhs{t}};
|
return {*static_cast<const Expr*>(this), rhs{t}};
|
||||||
}
|
}
|
||||||
@ -205,98 +205,98 @@ namespace sqlpp
|
|||||||
template <typename... T>
|
template <typename... T>
|
||||||
auto in(T... t) const -> typename _new_nary_expression<in_t, T...>::type
|
auto in(T... t) const -> typename _new_nary_expression<in_t, T...>::type
|
||||||
{
|
{
|
||||||
check_in_t<Expr, wrap_operand_t<T>...>::_();
|
check_in_t<Expr, wrap_operand_t<T>...>{};
|
||||||
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
auto not_in(T... t) const -> typename _new_nary_expression<not_in_t, T...>::type
|
auto not_in(T... t) const -> typename _new_nary_expression<not_in_t, T...>::type
|
||||||
{
|
{
|
||||||
check_in_t<Expr, wrap_operand_t<T>...>::_();
|
check_in_t<Expr, wrap_operand_t<T>...>{};
|
||||||
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
return {*static_cast<const Expr*>(this), typename wrap_operand<T>::type{t}...};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Defer = void>
|
template <typename Defer = void>
|
||||||
auto operator not() const -> return_type_not_t<Expr, Defer>
|
auto operator not() const -> return_type_not_t<Expr, Defer>
|
||||||
{
|
{
|
||||||
return_type_not<Expr, Defer>::check::_();
|
typename return_type_not<Expr, Defer>::check{};
|
||||||
return {*static_cast<const Expr*>(this)};
|
return {*static_cast<const Expr*>(this)};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator and(const R& r) const -> return_type_and_t<Expr, R>
|
auto operator and(const R& r) const -> return_type_and_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_and<Expr, R>::check::_();
|
typename return_type_and<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator&(const R& r) const -> return_type_bitwise_and_t<Expr, R>
|
auto operator&(const R& r) const -> return_type_bitwise_and_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_bitwise_and<Expr, R>::check::_();
|
typename return_type_bitwise_and<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator|(const R& r) const -> return_type_bitwise_or_t<Expr, R>
|
auto operator|(const R& r) const -> return_type_bitwise_or_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_bitwise_or<Expr, R>::check::_();
|
typename return_type_bitwise_or<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator or(const R& r) const -> return_type_or_t<Expr, R>
|
auto operator or(const R& r) const -> return_type_or_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_or<Expr, R>::check::_();
|
typename return_type_or<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator+(const R& r) const -> return_type_plus_t<Expr, R>
|
auto operator+(const R& r) const -> return_type_plus_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_plus<Expr, R>::check::_();
|
typename return_type_plus<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator-(const R& r) const -> return_type_minus_t<Expr, R>
|
auto operator-(const R& r) const -> return_type_minus_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_minus<Expr, R>::check::_();
|
typename return_type_minus<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator*(const R& r) const -> return_type_multiplies_t<Expr, R>
|
auto operator*(const R& r) const -> return_type_multiplies_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_multiplies<Expr, R>::check::_();
|
typename return_type_multiplies<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator/(const R& r) const -> return_type_divides_t<Expr, R>
|
auto operator/(const R& r) const -> return_type_divides_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_divides<Expr, R>::check::_();
|
typename return_type_divides<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
auto operator%(const R& r) const -> return_type_modulus_t<Expr, R>
|
auto operator%(const R& r) const -> return_type_modulus_t<Expr, R>
|
||||||
{
|
{
|
||||||
return_type_modulus<Expr, R>::check::_();
|
typename return_type_modulus<Expr, R>::check{};
|
||||||
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expr*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Defer = void>
|
template <typename Defer = void>
|
||||||
auto operator+() const -> return_type_unary_plus_t<Expr, Defer>
|
auto operator+() const -> return_type_unary_plus_t<Expr, Defer>
|
||||||
{
|
{
|
||||||
return_type_unary_plus<Expr, Defer>::check::_();
|
typename return_type_unary_plus<Expr, Defer>::check{};
|
||||||
return {*static_cast<const Expr*>(this)};
|
return {*static_cast<const Expr*>(this)};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Defer = void>
|
template <typename Defer = void>
|
||||||
auto operator-() const -> return_type_unary_minus_t<Expr, Defer>
|
auto operator-() const -> return_type_unary_minus_t<Expr, Defer>
|
||||||
{
|
{
|
||||||
return_type_unary_minus<Expr, Defer>::check::_();
|
typename return_type_unary_minus<Expr, Defer>::check{};
|
||||||
return {*static_cast<const Expr*>(this)};
|
return {*static_cast<const Expr*>(this)};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,6 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
struct consistent_t : std::true_type
|
struct consistent_t : std::true_type
|
||||||
{
|
{
|
||||||
static void _(){};
|
|
||||||
};
|
};
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2016, Roland Bock, Aaron Bishop
|
* Copyright (c) 2013-2017, Roland Bock, Aaron Bishop
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#ifndef SQLPP11_DATA_TYPES_H
|
#ifndef SQLPP11_DATA_TYPES_H
|
||||||
#define SQLPP11_DATA_TYPES_H
|
#define SQLPP11_DATA_TYPES_H
|
||||||
|
|
||||||
|
#include <sqlpp11/data_types/blob.h>
|
||||||
#include <sqlpp11/data_types/boolean.h>
|
#include <sqlpp11/data_types/boolean.h>
|
||||||
#include <sqlpp11/data_types/integral.h>
|
#include <sqlpp11/data_types/integral.h>
|
||||||
#include <sqlpp11/data_types/unsigned_integral.h>
|
#include <sqlpp11/data_types/unsigned_integral.h>
|
||||||
|
42
include/sqlpp11/data_types/blob.h
Normal file
42
include/sqlpp11/data_types/blob.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_H
|
||||||
|
#define SQLPP_BLOB_H
|
||||||
|
|
||||||
|
#include <sqlpp11/data_types/blob/data_type.h>
|
||||||
|
#include <sqlpp11/data_types/blob/operand.h>
|
||||||
|
#include <sqlpp11/data_types/blob/wrap_operand.h>
|
||||||
|
#include <sqlpp11/data_types/blob/expression_operators.h>
|
||||||
|
#include <sqlpp11/data_types/blob/column_operators.h>
|
||||||
|
#include <sqlpp11/data_types/blob/parameter_value.h>
|
||||||
|
#include <sqlpp11/data_types/blob/result_field.h>
|
||||||
|
|
||||||
|
// blob specific functions
|
||||||
|
#include <sqlpp11/data_types/text/like.h>
|
||||||
|
#include <sqlpp11/data_types/text/concat.h>
|
||||||
|
|
||||||
|
#endif
|
57
include/sqlpp11/data_types/blob/column_operators.h
Normal file
57
include/sqlpp11/data_types/blob/column_operators.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_COLUMN_OPERATORS_H
|
||||||
|
#define SQLPP_BLOB_COLUMN_OPERATORS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/assignment.h>
|
||||||
|
#include <sqlpp11/data_types/blob/data_type.h>
|
||||||
|
#include <sqlpp11/data_types/column_operators.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename... Args>
|
||||||
|
struct concat_t;
|
||||||
|
|
||||||
|
template <typename Column>
|
||||||
|
struct column_operators<Column, blob>
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
using _is_valid_operand = is_valid_operand<blob, T>;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
auto operator+=(T t) const -> assignment_t<Column, concat_t<Column, wrap_operand_t<T>>>
|
||||||
|
{
|
||||||
|
using rhs = wrap_operand_t<T>;
|
||||||
|
static_assert(_is_valid_operand<rhs>::value, "invalid rhs assignment operand");
|
||||||
|
|
||||||
|
return {*static_cast<const Column*>(this),
|
||||||
|
concat_t<Column, wrap_operand_t<T>>{*static_cast<const Column*>(this), rhs{t}}};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
49
include/sqlpp11/data_types/blob/data_type.h
Normal file
49
include/sqlpp11/data_types/blob/data_type.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_DATA_TYPE_H
|
||||||
|
#define SQLPP_BLOB_DATA_TYPE_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/logic.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
struct blob
|
||||||
|
{
|
||||||
|
using _traits = make_traits<blob, tag::is_value_type>;
|
||||||
|
using _cpp_value_type = std::vector<std::uint8_t>;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using _is_valid_operand = ::sqlpp::logic::any_t<is_blob_t<T>::value, is_text_t<T>::value>;
|
||||||
|
};
|
||||||
|
|
||||||
|
using blob = blob;
|
||||||
|
using mediumblob = blob;
|
||||||
|
}
|
||||||
|
#endif
|
70
include/sqlpp11/data_types/blob/expression_operators.h
Normal file
70
include/sqlpp11/data_types/blob/expression_operators.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_EXPRESSION_OPERATORS_H
|
||||||
|
#define SQLPP_BLOB_EXPRESSION_OPERATORS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/operand_check.h>
|
||||||
|
#include <sqlpp11/expression_operators.h>
|
||||||
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/data_types/blob/data_type.h>
|
||||||
|
#include <sqlpp11/data_types/text/return_type_like.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename Operand, typename Pattern>
|
||||||
|
struct like_t;
|
||||||
|
|
||||||
|
template <typename L, typename R>
|
||||||
|
struct return_type_like<L, R, binary_operand_check_t<L, is_blob_t, R, is_blob_t>>
|
||||||
|
{
|
||||||
|
using check = consistent_t;
|
||||||
|
using type = like_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename L, typename R>
|
||||||
|
struct return_type_like<L, R, binary_operand_check_t<L, is_blob_t, R, is_text_t>>
|
||||||
|
{
|
||||||
|
using check = consistent_t;
|
||||||
|
using type = like_t<wrap_operand_t<L>, wrap_operand_t<R>>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Expression>
|
||||||
|
struct expression_operators<Expression, blob> : public basic_expression_operators<Expression>
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
using _is_valid_operand = is_valid_operand<blob, T>;
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
auto like(const R& r) const -> return_type_like_t<Expression, R>
|
||||||
|
{
|
||||||
|
typename return_type_like<Expression, R>::check{};
|
||||||
|
return {*static_cast<const Expression*>(this), wrap_operand_t<R>{r}};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace sqlpp
|
||||||
|
#endif
|
94
include/sqlpp11/data_types/blob/operand.h
Normal file
94
include/sqlpp11/data_types/blob/operand.h
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_OPERAND_H
|
||||||
|
#define SQLPP_BLOB_OPERAND_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/alias_operators.h>
|
||||||
|
#include <sqlpp11/serializer.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
struct blob;
|
||||||
|
|
||||||
|
struct blob_operand : public alias_operators<blob_operand>
|
||||||
|
{
|
||||||
|
using _traits = make_traits<blob, tag::is_expression, tag::is_wrapped_value>;
|
||||||
|
using _nodes = detail::type_vector<>;
|
||||||
|
using _is_aggregate_expression = std::true_type;
|
||||||
|
|
||||||
|
using _value_t = std::vector<std::uint8_t>;
|
||||||
|
|
||||||
|
blob_operand() : _t{}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
blob_operand(_value_t t) : _t(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
blob_operand(const std::array<uint8_t, N>& t) : _t(t.begin(), t.end())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
blob_operand(const blob_operand&) = default;
|
||||||
|
blob_operand(blob_operand&&) = default;
|
||||||
|
blob_operand& operator=(const blob_operand&) = default;
|
||||||
|
blob_operand& operator=(blob_operand&&) = default;
|
||||||
|
~blob_operand() = default;
|
||||||
|
|
||||||
|
bool _is_trivial() const
|
||||||
|
{
|
||||||
|
return _t.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
_value_t _t;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Context>
|
||||||
|
struct serializer_t<Context, blob_operand>
|
||||||
|
{
|
||||||
|
using _serialize_check = consistent_t;
|
||||||
|
using Operand = blob_operand;
|
||||||
|
|
||||||
|
static Context& _(const Operand& t, Context& context)
|
||||||
|
{
|
||||||
|
constexpr char hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||||
|
context << "x'";
|
||||||
|
for (const auto c : t._t)
|
||||||
|
{
|
||||||
|
context << hexChars[c >> 4] << hexChars[c & 0x0F];
|
||||||
|
}
|
||||||
|
context << '\'';
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
53
include/sqlpp11/data_types/blob/parameter_value.h
Normal file
53
include/sqlpp11/data_types/blob/parameter_value.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_PARAMETER_VALUE_H
|
||||||
|
#define SQLPP_BLOB_PARAMETER_VALUE_H
|
||||||
|
|
||||||
|
#include <sqlpp11/data_types/parameter_value.h>
|
||||||
|
#include <sqlpp11/data_types/parameter_value_base.h>
|
||||||
|
#include <sqlpp11/data_types/blob/data_type.h>
|
||||||
|
#include <sqlpp11/data_types/blob/wrap_operand.h>
|
||||||
|
#include <sqlpp11/data_types/blob/operand.h>
|
||||||
|
#include <sqlpp11/tvin.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
struct parameter_value_t<blob> : public parameter_value_base<blob>
|
||||||
|
{
|
||||||
|
using base = parameter_value_base<blob>;
|
||||||
|
using base::base;
|
||||||
|
using base::operator=;
|
||||||
|
|
||||||
|
template <typename Target>
|
||||||
|
void _bind(Target& target, size_t index) const
|
||||||
|
{
|
||||||
|
target._bind_blob_parameter(index, &_value, _is_null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
83
include/sqlpp11/data_types/blob/result_field.h
Normal file
83
include/sqlpp11/data_types/blob/result_field.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_RESULT_FIELD_H
|
||||||
|
#define SQLPP_BLOB_RESULT_FIELD_H
|
||||||
|
|
||||||
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
|
#include <sqlpp11/result_field.h>
|
||||||
|
#include <sqlpp11/result_field_base.h>
|
||||||
|
#include <sqlpp11/data_types/blob/data_type.h>
|
||||||
|
#include <sqlpp11/field_spec.h>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||||
|
struct result_field_t<Db, field_spec_t<NameType, blob, CanBeNull, NullIsTrivialValue>>
|
||||||
|
: public result_field_base<Db, field_spec_t<NameType, blob, CanBeNull, NullIsTrivialValue>>
|
||||||
|
{
|
||||||
|
const uint8_t* blob{nullptr}; // Non-owning
|
||||||
|
size_t len{};
|
||||||
|
|
||||||
|
template <typename Target>
|
||||||
|
void _bind(Target& target, size_t index)
|
||||||
|
{
|
||||||
|
target._bind_blob_result(index, &blob, &len);
|
||||||
|
if (blob)
|
||||||
|
this->_value.assign(blob, blob+len);
|
||||||
|
else
|
||||||
|
this->_value.clear();
|
||||||
|
this->_is_null = (blob == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Target>
|
||||||
|
void _post_bind(Target& target, size_t index)
|
||||||
|
{
|
||||||
|
target._post_bind_blob_result(index, &blob, &len);
|
||||||
|
if (blob)
|
||||||
|
this->_value.assign(blob, blob+len);
|
||||||
|
else
|
||||||
|
this->_value.clear();
|
||||||
|
this->_is_null = (blob == nullptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Db, typename NameType, bool CanBeNull, bool NullIsTrivialValue>
|
||||||
|
inline std::ostream& operator<<(
|
||||||
|
std::ostream& os, const result_field_t<Db, field_spec_t<NameType, blob, CanBeNull, NullIsTrivialValue>>& e)
|
||||||
|
{
|
||||||
|
if (e.is_null() and not NullIsTrivialValue)
|
||||||
|
{
|
||||||
|
return os << "NULL";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return os << e.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
51
include/sqlpp11/data_types/blob/wrap_operand.h
Normal file
51
include/sqlpp11/data_types/blob/wrap_operand.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_BLOB_WRAP_OPERAND_H
|
||||||
|
#define SQLPP_BLOB_WRAP_OPERAND_H
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/wrap_operand.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
struct blob_operand;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct wrap_operand<std::vector<std::uint8_t>, void>
|
||||||
|
{
|
||||||
|
using type = blob_operand;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct wrap_operand<std::array<std::uint8_t, N>, void>
|
||||||
|
{
|
||||||
|
using type = blob_operand;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
@ -40,7 +40,6 @@ namespace sqlpp
|
|||||||
using _is_valid_operand = is_text_t<T>;
|
using _is_valid_operand = is_text_t<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
using blob = text;
|
|
||||||
using varchar = text;
|
using varchar = text;
|
||||||
using char_ = text;
|
using char_ = text;
|
||||||
using binary = text;
|
using binary = text;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <sqlpp11/basic_expression_operators.h>
|
#include <sqlpp11/basic_expression_operators.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
#include <sqlpp11/data_types/text/data_type.h>
|
#include <sqlpp11/data_types/text/data_type.h>
|
||||||
|
#include <sqlpp11/data_types/text/return_type_like.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
@ -40,15 +41,6 @@ namespace sqlpp
|
|||||||
template <typename Operand, typename Pattern>
|
template <typename Operand, typename Pattern>
|
||||||
struct like_t;
|
struct like_t;
|
||||||
|
|
||||||
template <typename T, typename Defer, typename Enable = void>
|
|
||||||
struct return_type_like
|
|
||||||
{
|
|
||||||
using check = assert_valid_operands;
|
|
||||||
using type = bad_expression<boolean>;
|
|
||||||
};
|
|
||||||
template <typename T, typename Defer>
|
|
||||||
using return_type_like_t = typename return_type_like<T, Defer>::type;
|
|
||||||
|
|
||||||
template <typename L, typename R>
|
template <typename L, typename R>
|
||||||
struct return_type_like<L, R, binary_operand_check_t<L, is_text_t, R, is_text_t>>
|
struct return_type_like<L, R, binary_operand_check_t<L, is_text_t, R, is_text_t>>
|
||||||
{
|
{
|
||||||
@ -65,7 +57,7 @@ namespace sqlpp
|
|||||||
template <typename R>
|
template <typename R>
|
||||||
auto like(const R& r) const -> return_type_like_t<Expression, R>
|
auto like(const R& r) const -> return_type_like_t<Expression, R>
|
||||||
{
|
{
|
||||||
return_type_like<Expression, R>::check::_();
|
typename return_type_like<Expression, R>::check{};
|
||||||
return {*static_cast<const Expression*>(this), wrap_operand_t<R>{r}};
|
return {*static_cast<const Expression*>(this), wrap_operand_t<R>{r}};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
44
include/sqlpp11/data_types/text/return_type_like.h
Normal file
44
include/sqlpp11/data_types/text/return_type_like.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2017, 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_RETURN_TYPE_LIKE_H
|
||||||
|
#define SQLPP_RETURN_TYPE_LIKE_H
|
||||||
|
|
||||||
|
#include <sqlpp11/bad_expression.h>
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
template <typename T, typename Defer, typename Enable = void>
|
||||||
|
struct return_type_like
|
||||||
|
{
|
||||||
|
using check = assert_valid_operands;
|
||||||
|
using type = bad_expression<boolean>;
|
||||||
|
};
|
||||||
|
template <typename T, typename Defer>
|
||||||
|
using return_type_like_t = typename return_type_like<T, Defer>::type;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -27,6 +27,7 @@
|
|||||||
#ifndef SQLPP11_FUNCTIONS_H
|
#ifndef SQLPP11_FUNCTIONS_H
|
||||||
#define SQLPP11_FUNCTIONS_H
|
#define SQLPP11_FUNCTIONS_H
|
||||||
|
|
||||||
|
#include <sqlpp11/noop.h>
|
||||||
#include <sqlpp11/parameter.h>
|
#include <sqlpp11/parameter.h>
|
||||||
#include <sqlpp11/parameter_list.h>
|
#include <sqlpp11/parameter_list.h>
|
||||||
#include <sqlpp11/data_types.h>
|
#include <sqlpp11/data_types.h>
|
||||||
|
@ -123,8 +123,8 @@ namespace sqlpp
|
|||||||
template <typename Database, typename... Assignments>
|
template <typename Database, typename... Assignments>
|
||||||
struct insert_list_data_t
|
struct insert_list_data_t
|
||||||
{
|
{
|
||||||
insert_list_data_t(Assignments... assignments)
|
insert_list_data_t(std::tuple<Assignments...> assignments)
|
||||||
: _assignments(assignments...), _columns(assignments._lhs...), _values(assignments._rhs...)
|
: _assignments(assignments), _columns( columns_from_tuple(assignments) ), _values( values_from_tuple(assignments) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,6 +140,31 @@ namespace sqlpp
|
|||||||
std::tuple<rhs_t<Assignments>...> _values;
|
std::tuple<rhs_t<Assignments>...> _values;
|
||||||
interpretable_list_t<Database> _dynamic_columns;
|
interpretable_list_t<Database> _dynamic_columns;
|
||||||
interpretable_list_t<Database> _dynamic_values;
|
interpretable_list_t<Database> _dynamic_values;
|
||||||
|
private:
|
||||||
|
template< size_t... Indexes >
|
||||||
|
auto columns_from_tuple( detail::index_sequence<Indexes... >, std::tuple<Assignments ...> assignments ) -> decltype (_columns)
|
||||||
|
{
|
||||||
|
(void) assignments;
|
||||||
|
return decltype(_columns)(std::get<Indexes>(assignments)._lhs...);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto columns_from_tuple(std::tuple<Assignments ...> assignments) -> decltype (_columns) {
|
||||||
|
const auto seq = detail::make_index_sequence<sizeof... (Assignments)>{};
|
||||||
|
return columns_from_tuple(seq, assignments);
|
||||||
|
}
|
||||||
|
|
||||||
|
template< size_t... Indexes >
|
||||||
|
auto values_from_tuple( detail::index_sequence<Indexes... >, std::tuple<Assignments ...> assignments ) -> decltype(_values)
|
||||||
|
{
|
||||||
|
(void) assignments;
|
||||||
|
return decltype(_values)(std::get<Indexes>(assignments)._rhs...);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto values_from_tuple( std::tuple<Assignments ...> assignments ) -> decltype(_values)
|
||||||
|
{
|
||||||
|
const auto seq = detail::make_index_sequence<sizeof... (Assignments)>{};
|
||||||
|
return values_from_tuple(seq, assignments);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_insert_set_assignments_t, "at least one argument is not an assignment in set()");
|
SQLPP_PORTABLE_STATIC_ASSERT(assert_insert_set_assignments_t, "at least one argument is not an assignment in set()");
|
||||||
@ -511,16 +536,32 @@ namespace sqlpp
|
|||||||
-> _new_statement_t<check_insert_static_set_t<Assignments...>, insert_list_t<void, Assignments...>>
|
-> _new_statement_t<check_insert_static_set_t<Assignments...>, insert_list_t<void, Assignments...>>
|
||||||
{
|
{
|
||||||
using Check = check_insert_static_set_t<Assignments...>;
|
using Check = check_insert_static_set_t<Assignments...>;
|
||||||
return _set_impl<void>(Check{}, assignments...);
|
return _set_impl<void>(Check{}, std::make_tuple(assignments...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename... Assignments>
|
||||||
|
auto set(std::tuple<Assignments...> assignments) const
|
||||||
|
-> _new_statement_t<check_insert_static_set_t<Assignments...>, insert_list_t<void, Assignments...>>
|
||||||
|
{
|
||||||
|
using Check = check_insert_static_set_t<Assignments...>;
|
||||||
|
return _set_impl<void>(Check{}, assignments);
|
||||||
|
}
|
||||||
template <typename... Assignments>
|
template <typename... Assignments>
|
||||||
auto dynamic_set(Assignments... assignments) const
|
auto dynamic_set(Assignments... assignments) const
|
||||||
-> _new_statement_t<check_insert_dynamic_set_t<_database_t, Assignments...>,
|
-> _new_statement_t<check_insert_dynamic_set_t<_database_t, Assignments...>,
|
||||||
insert_list_t<_database_t, Assignments...>>
|
insert_list_t<_database_t, Assignments...>>
|
||||||
{
|
{
|
||||||
using Check = check_insert_dynamic_set_t<_database_t, Assignments...>;
|
using Check = check_insert_dynamic_set_t<_database_t, Assignments...>;
|
||||||
return _set_impl<_database_t>(Check{}, assignments...);
|
return _set_impl<_database_t>(Check{}, std::make_tuple(assignments...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Assignments>
|
||||||
|
auto dynamic_set(std::tuple<Assignments...> assignments) const
|
||||||
|
-> _new_statement_t<check_insert_dynamic_set_t<_database_t, Assignments...>,
|
||||||
|
insert_list_t<_database_t, Assignments...>>
|
||||||
|
{
|
||||||
|
using Check = check_insert_dynamic_set_t<_database_t, Assignments...>;
|
||||||
|
return _set_impl<_database_t>(Check{}, assignments);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -548,11 +589,11 @@ namespace sqlpp
|
|||||||
auto _set_impl(Check, Assignments... assignments) const -> inconsistent<Check>;
|
auto _set_impl(Check, Assignments... assignments) const -> inconsistent<Check>;
|
||||||
|
|
||||||
template <typename Database, typename... Assignments>
|
template <typename Database, typename... Assignments>
|
||||||
auto _set_impl(consistent_t /*unused*/, Assignments... assignments) const
|
auto _set_impl(consistent_t /*unused*/,std::tuple<Assignments...> assignments) const
|
||||||
-> _new_statement_t<consistent_t, insert_list_t<Database, Assignments...>>
|
-> _new_statement_t<consistent_t, insert_list_t<Database, Assignments...>>
|
||||||
{
|
{
|
||||||
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
||||||
insert_list_data_t<Database, Assignments...>{assignments...}};
|
insert_list_data_t<Database, Assignments...>{assignments}};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
#include <sqlpp11/ppgen/colops/foreign_key.h>
|
#include <sqlpp11/ppgen/colops/foreign_key.h>
|
||||||
#include <sqlpp11/ppgen/colops/index.h>
|
#include <sqlpp11/ppgen/colops/index.h>
|
||||||
#include <sqlpp11/ppgen/colops/integer.h>
|
#include <sqlpp11/ppgen/colops/integer.h>
|
||||||
|
#include <sqlpp11/ppgen/colops/unsigned_integer.h>
|
||||||
#include <sqlpp11/ppgen/colops/not_null.h>
|
#include <sqlpp11/ppgen/colops/not_null.h>
|
||||||
#include <sqlpp11/ppgen/colops/null.h>
|
#include <sqlpp11/ppgen/colops/null.h>
|
||||||
#include <sqlpp11/ppgen/colops/primary_key.h>
|
#include <sqlpp11/ppgen/colops/primary_key.h>
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_float(...) \
|
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_float(...) \
|
||||||
::sqlpp::floating_point
|
::sqlpp::floating_point
|
||||||
|
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_real \
|
||||||
|
PROC_real
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_real(...) \
|
||||||
|
::sqlpp::floating_point
|
||||||
|
|
||||||
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_double \
|
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_double \
|
||||||
PROC_double
|
PROC_double
|
||||||
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_double(...) \
|
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_double(...) \
|
||||||
|
52
include/sqlpp11/ppgen/colops/unsigned_integer.h
Normal file
52
include/sqlpp11/ppgen/colops/unsigned_integer.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014-2017, Damien COJAN
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
|
#ifndef _sqlpp__ppgen__colops__unsigned_integer_h
|
||||||
|
#define _sqlpp__ppgen__colops__unsigned_integer_h
|
||||||
|
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_tinyint_unsigned \
|
||||||
|
PROC_tinyint_unsigned
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_tinyint_unsigned(...) \
|
||||||
|
::sqlpp::tinyint_unsigned
|
||||||
|
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_smallint_unsigned \
|
||||||
|
PROC_smallint_unsigned
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_smallint_unsigned(...) \
|
||||||
|
::sqlpp::smallint_unsigned
|
||||||
|
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_int_unsigned \
|
||||||
|
PROC_int_unsigned
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_int_unsigned(...) \
|
||||||
|
::sqlpp::integer_unsigned
|
||||||
|
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_bigint_unsigned \
|
||||||
|
PROC_bigint_unsigned
|
||||||
|
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_bigint_unsigned(...) \
|
||||||
|
::sqlpp::bigint_unsigned
|
||||||
|
|
||||||
|
#endif // _sqlpp__ppgen__colops__unsigned_integer_h
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2016, Roland Bock, Aaron Bishop
|
* Copyright (c) 2013-2017, Roland Bock, Aaron Bishop
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -63,6 +63,10 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
// data types
|
// data types
|
||||||
|
struct blob;
|
||||||
|
template <typename T>
|
||||||
|
using is_blob_t = std::is_same<value_type_of<T>, blob>;
|
||||||
|
|
||||||
struct boolean;
|
struct boolean;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_boolean_t = std::is_same<value_type_of<T>, boolean>;
|
using is_boolean_t = std::is_same<value_type_of<T>, boolean>;
|
||||||
|
@ -38,7 +38,7 @@ namespace sqlpp
|
|||||||
template <typename Database, typename... Assignments>
|
template <typename Database, typename... Assignments>
|
||||||
struct update_list_data_t
|
struct update_list_data_t
|
||||||
{
|
{
|
||||||
update_list_data_t(Assignments... assignments) : _assignments(assignments...)
|
update_list_data_t(std::tuple<Assignments ...> assignments ) : _assignments(assignments)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,15 @@ namespace sqlpp
|
|||||||
-> _new_statement_t<check_update_static_set_t<Assignments...>, update_list_t<void, Assignments...>>
|
-> _new_statement_t<check_update_static_set_t<Assignments...>, update_list_t<void, Assignments...>>
|
||||||
{
|
{
|
||||||
using Check = check_update_static_set_t<Assignments...>;
|
using Check = check_update_static_set_t<Assignments...>;
|
||||||
return _set_impl<void>(Check{}, assignments...);
|
return _set_impl<void>(Check{}, std::make_tuple(assignments...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Assignments>
|
||||||
|
auto set(std::tuple<Assignments...> assignments) const
|
||||||
|
-> _new_statement_t<check_update_static_set_t<Assignments...>, update_list_t<void, Assignments...>>
|
||||||
|
{
|
||||||
|
using Check = check_update_static_set_t<Assignments...>;
|
||||||
|
return _set_impl<void>(Check{}, assignments);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Assignments>
|
template <typename... Assignments>
|
||||||
@ -267,7 +275,7 @@ namespace sqlpp
|
|||||||
update_list_t<_database_t, Assignments...>>
|
update_list_t<_database_t, Assignments...>>
|
||||||
{
|
{
|
||||||
using Check = check_update_dynamic_set_t<_database_t, Assignments...>;
|
using Check = check_update_dynamic_set_t<_database_t, Assignments...>;
|
||||||
return _set_impl<_database_t>(Check{}, assignments...);
|
return _set_impl<_database_t>(Check{}, std::make_tuple(assignments...));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -275,11 +283,11 @@ namespace sqlpp
|
|||||||
auto _set_impl(Check, Assignments... assignments) const -> inconsistent<Check>;
|
auto _set_impl(Check, Assignments... assignments) const -> inconsistent<Check>;
|
||||||
|
|
||||||
template <typename Database, typename... Assignments>
|
template <typename Database, typename... Assignments>
|
||||||
auto _set_impl(consistent_t /*unused*/, Assignments... assignments) const
|
auto _set_impl(consistent_t /*unused*/, std::tuple<Assignments...> assignments) const
|
||||||
-> _new_statement_t<consistent_t, update_list_t<Database, Assignments...>>
|
-> _new_statement_t<consistent_t, update_list_t<Database, Assignments...>>
|
||||||
{
|
{
|
||||||
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
return {static_cast<const derived_statement_t<Policies>&>(*this),
|
||||||
update_list_data_t<Database, Assignments...>{assignments...}};
|
update_list_data_t<Database, Assignments...>{assignments}};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -45,17 +45,29 @@ from pyparsing import CaselessLiteral, Literal, SkipTo, restOfLine, oneOf, ZeroO
|
|||||||
# HELPERS
|
# HELPERS
|
||||||
|
|
||||||
def get_include_guard_name(namespace, inputfile):
|
def get_include_guard_name(namespace, inputfile):
|
||||||
val = re.sub("[^A-Za-z]+", "_", namespace + '_' + os.path.basename(inputfile))
|
val = re.sub("[^A-Za-z0-9]+", "_", namespace + '_' + os.path.basename(inputfile))
|
||||||
return val.upper()
|
return val.upper()
|
||||||
|
|
||||||
|
def identity_naming_func(s):
|
||||||
|
return s
|
||||||
|
|
||||||
def repl_func(m):
|
def repl_camel_case_func(m):
|
||||||
if m.group(1) == '_':
|
if m.group(1) == '_':
|
||||||
return m.group(2).upper()
|
return m.group(2).upper()
|
||||||
else:
|
else:
|
||||||
return m.group(1) + m.group(2).upper()
|
return m.group(1) + m.group(2).upper()
|
||||||
|
|
||||||
|
|
||||||
|
def class_name_naming_func(s):
|
||||||
|
return re.sub("(^|\s|[_0-9])(\S)", repl_camel_case_func, s)
|
||||||
|
|
||||||
|
|
||||||
|
def member_name_naming_func(s):
|
||||||
|
return re.sub("(\s|_|[0-9])(\S)", repl_camel_case_func, s)
|
||||||
|
|
||||||
|
toClassName = class_name_naming_func
|
||||||
|
toMemberName = member_name_naming_func
|
||||||
|
|
||||||
def repl_func_for_args(m):
|
def repl_func_for_args(m):
|
||||||
if m.group(1) == '-':
|
if m.group(1) == '-':
|
||||||
return m.group(2).upper()
|
return m.group(2).upper()
|
||||||
@ -113,6 +125,7 @@ optionalArgs = {
|
|||||||
'-fail-on-parse': "abort instead of silent genereation of unusable headers", # failOnParse = True
|
'-fail-on-parse': "abort instead of silent genereation of unusable headers", # failOnParse = True
|
||||||
'-warn-on-parse': "warn about unusable headers, but continue", # warnOnParse = True
|
'-warn-on-parse': "warn about unusable headers, but continue", # warnOnParse = True
|
||||||
'-auto-id': "Assume column 'id' to have an automatic value as if AUTO_INCREMENT was specified (e.g. implicit for SQLite ROWID)", # autoId = True
|
'-auto-id': "Assume column 'id' to have an automatic value as if AUTO_INCREMENT was specified (e.g. implicit for SQLite ROWID)", # autoId = True
|
||||||
|
'-identity-naming': "Use table and column names from the ddl (defaults to UpperCamelCase for tables and lowerCamelCase for columns", # identityNaming = True
|
||||||
'-help': "show this help"
|
'-help': "show this help"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +142,7 @@ failOnParse = False
|
|||||||
warnOnParse = False
|
warnOnParse = False
|
||||||
parseError = "Parsing error, possible reason: can't parse default value for a field"
|
parseError = "Parsing error, possible reason: can't parse default value for a field"
|
||||||
autoId = False
|
autoId = False
|
||||||
|
identityNaming = False
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) >= 4:
|
if len(sys.argv) >= 4:
|
||||||
@ -143,6 +157,10 @@ if len(sys.argv) >= 4:
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if identityNaming:
|
||||||
|
toClassName = identity_naming_func
|
||||||
|
toMemberName = identity_naming_func
|
||||||
|
|
||||||
pathToDdl = sys.argv[firstPositional]
|
pathToDdl = sys.argv[firstPositional]
|
||||||
|
|
||||||
pathToHeader = sys.argv[firstPositional + 1] + '.h'
|
pathToHeader = sys.argv[firstPositional + 1] + '.h'
|
||||||
@ -168,7 +186,16 @@ negativeSign = Literal('-')
|
|||||||
ddlNum = Combine(Optional(negativeSign) + Word(nums + "."))
|
ddlNum = Combine(Optional(negativeSign) + Word(nums + "."))
|
||||||
ddlTerm = Word(alphanums + "_$")
|
ddlTerm = Word(alphanums + "_$")
|
||||||
ddlName = Or([ddlTerm, ddlString])
|
ddlName = Or([ddlTerm, ddlString])
|
||||||
|
ddlMathOp = Word("+><=-")
|
||||||
|
ddlBoolean = Or([ddlWord("AND"), ddlWord("OR"), ddlWord("NOT")])
|
||||||
ddlArguments = "(" + delimitedList(Or([ddlString, ddlTerm, ddlNum])) + ")"
|
ddlArguments = "(" + delimitedList(Or([ddlString, ddlTerm, ddlNum])) + ")"
|
||||||
|
ddlMathCond = "(" + delimitedList(
|
||||||
|
Or([
|
||||||
|
Group(ddlName + ddlMathOp + ddlName),
|
||||||
|
Group(ddlName + ddlWord("NOT") + ddlWord("NULL")),
|
||||||
|
]),
|
||||||
|
delim=ddlBoolean) + ")"
|
||||||
|
|
||||||
ddlUnsigned = ddlWord("unsigned").setResultsName("isUnsigned")
|
ddlUnsigned = ddlWord("unsigned").setResultsName("isUnsigned")
|
||||||
ddlNotNull = Group(ddlWord("NOT") + ddlWord("NULL")).setResultsName("notNull")
|
ddlNotNull = Group(ddlWord("NOT") + ddlWord("NULL")).setResultsName("notNull")
|
||||||
ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue")
|
ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue")
|
||||||
@ -186,8 +213,9 @@ ddlConstraint = Or([
|
|||||||
ddlWord("KEY"),
|
ddlWord("KEY"),
|
||||||
ddlWord("INDEX"),
|
ddlWord("INDEX"),
|
||||||
ddlWord("UNIQUE"),
|
ddlWord("UNIQUE"),
|
||||||
|
ddlWord("CHECK")
|
||||||
])
|
])
|
||||||
ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlUnsigned, ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments])))
|
ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlUnsigned, ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments, ddlMathCond])))
|
||||||
ddlIfNotExists = Optional(Group(ddlWord("IF") + ddlWord("NOT") + ddlWord("EXISTS")).setResultsName("ifNotExists"))
|
ddlIfNotExists = Optional(Group(ddlWord("IF") + ddlWord("NOT") + ddlWord("EXISTS")).setResultsName("ifNotExists"))
|
||||||
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlIfNotExists + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")
|
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlIfNotExists + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")
|
||||||
#ddlString.setDebug(True) #uncomment to debug pyparsing
|
#ddlString.setDebug(True) #uncomment to debug pyparsing
|
||||||
@ -202,15 +230,20 @@ types = {
|
|||||||
'tinyint': 'tinyint',
|
'tinyint': 'tinyint',
|
||||||
'smallint': 'smallint',
|
'smallint': 'smallint',
|
||||||
'smallserial': 'smallint', # PostgreSQL
|
'smallserial': 'smallint', # PostgreSQL
|
||||||
|
'int2': 'smallint', #PostgreSQL
|
||||||
'integer': 'integer',
|
'integer': 'integer',
|
||||||
'int': 'integer',
|
'int': 'integer',
|
||||||
'serial': 'integer', # PostgreSQL
|
'serial': 'integer', # PostgreSQL
|
||||||
|
'int4': 'integer', #PostgreSQL
|
||||||
'mediumint' : 'integer',
|
'mediumint' : 'integer',
|
||||||
'bigint': 'bigint',
|
'bigint': 'bigint',
|
||||||
'bigserial': 'bigint', # PostgreSQL
|
'bigserial': 'bigint', # PostgreSQL
|
||||||
|
'int8': 'bigint', #PostgreSQL
|
||||||
'char': 'char_',
|
'char': 'char_',
|
||||||
'varchar': 'varchar',
|
'varchar': 'varchar',
|
||||||
|
'character varying': 'varchar', #PostgreSQL
|
||||||
'text': 'text',
|
'text': 'text',
|
||||||
|
'clob': 'text',
|
||||||
'tinyblob': 'blob',
|
'tinyblob': 'blob',
|
||||||
'blob': 'blob',
|
'blob': 'blob',
|
||||||
'mediumblob': 'blob',
|
'mediumblob': 'blob',
|
||||||
@ -218,13 +251,22 @@ types = {
|
|||||||
'bool': 'boolean',
|
'bool': 'boolean',
|
||||||
'boolean': 'boolean',
|
'boolean': 'boolean',
|
||||||
'double': 'floating_point',
|
'double': 'floating_point',
|
||||||
|
'float8': 'floating_point', # PostgreSQL
|
||||||
'float': 'floating_point',
|
'float': 'floating_point',
|
||||||
'real': 'floating_point',
|
'float4': 'floating_point', # PostgreSQL
|
||||||
|
'numeric': 'floating_point', # PostgreSQL
|
||||||
'date': 'day_point',
|
'date': 'day_point',
|
||||||
'datetime': 'time_point',
|
'datetime': 'time_point',
|
||||||
|
'time without time zone': 'time_point', # PostgreSQL
|
||||||
|
'time with time zone': 'time_point', # PostgreSQL
|
||||||
'timestamp': 'time_point',
|
'timestamp': 'time_point',
|
||||||
|
'timestamp without time zone': 'time_point', # PostgreSQL
|
||||||
|
'timestamp with time zone': 'time_point', # PostgreSQL
|
||||||
|
'timestamptz': 'time_point', # PostgreSQL
|
||||||
'enum': 'text', # MYSQL
|
'enum': 'text', # MYSQL
|
||||||
'set': 'text', # MYSQL,
|
'set': 'text', # MYSQL,
|
||||||
|
'json' : 'text', # PostgreSQL
|
||||||
|
'jsonb' : 'text', # PostgreSQL
|
||||||
'tinyint unsigned': 'tinyint_unsigned', #MYSQL
|
'tinyint unsigned': 'tinyint_unsigned', #MYSQL
|
||||||
'smallint unsigned': 'smallint_unsigned', #MYSQL
|
'smallint unsigned': 'smallint_unsigned', #MYSQL
|
||||||
'integer unsigned': 'integer_unsigned', #MYSQL
|
'integer unsigned': 'integer_unsigned', #MYSQL
|
||||||
|
@ -58,16 +58,26 @@ if (${PYTHONINTERP_FOUND})
|
|||||||
"${CMAKE_CURRENT_BINARY_DIR}/fail"
|
"${CMAKE_CURRENT_BINARY_DIR}/fail"
|
||||||
test)
|
test)
|
||||||
|
|
||||||
set(sqlpp.test.generated.sample "${CMAKE_CURRENT_BINARY_DIR}/Sample")
|
foreach(sample_name sample sample_identity_naming)
|
||||||
|
set(sqlpp.test.generated.sample.include "${CMAKE_CURRENT_BINARY_DIR}/${sample_name}")
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set(use_identity_naming)
|
||||||
|
if(sample_name STREQUAL "sample_identity_naming")
|
||||||
|
set(use_identity_naming -identity-naming)
|
||||||
|
endif()
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${sqlpp.test.generated.sample}.h"
|
OUTPUT "${sqlpp.test.generated.sample.include}.h"
|
||||||
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../scripts/ddl2cpp" "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql" "${sqlpp.test.generated.sample}" test
|
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../scripts/ddl2cpp"
|
||||||
|
${use_identity_naming}
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql"
|
||||||
|
"${sqlpp.test.generated.sample.include}"
|
||||||
|
test
|
||||||
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql"
|
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
add_executable(sqlpp.test.compiled.sample sample.cpp "${sqlpp.test.generated.sample}.h")
|
add_executable(sqlpp.test.compiled.${sample_name} ${sample_name}.cpp "${sqlpp.test.generated.sample.include}.h")
|
||||||
target_link_libraries(sqlpp.test.compiled.sample PRIVATE sqlpp11)
|
target_link_libraries(sqlpp.test.compiled.${sample_name} PRIVATE sqlpp11)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
#include <Sample.h>
|
#include <sample.h>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
test::TabFoo tab_foo;
|
||||||
|
tab_foo.delta = "delta";
|
||||||
|
tab_foo.Epsilon = 42;
|
||||||
|
tab_foo.omega = 3.14;
|
||||||
|
|
||||||
|
test::TabBar tab_bar;
|
||||||
|
tab_bar.alpha = 42;
|
||||||
|
tab_bar.beta = "beta";
|
||||||
|
tab_bar.gamma = true;
|
||||||
|
tab_bar.delta = 42;
|
||||||
}
|
}
|
||||||
|
15
test_scripts/sample_identity_naming.cpp
Normal file
15
test_scripts/sample_identity_naming.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <sample_identity_naming.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test::tab_foo tab_foo;
|
||||||
|
tab_foo.delta = "delta";
|
||||||
|
tab_foo._epsilon = 42;
|
||||||
|
tab_foo.omega = 3.14;
|
||||||
|
|
||||||
|
test::tab_bar tab_bar;
|
||||||
|
tab_bar.alpha = 42;
|
||||||
|
tab_bar.beta = "beta";
|
||||||
|
tab_bar.gamma = true;
|
||||||
|
tab_bar.delta = 42;
|
||||||
|
}
|
72
test_serializer/Blob.cpp
Normal file
72
test_serializer/Blob.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 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 "compare.h"
|
||||||
|
#include "Sample.h"
|
||||||
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
auto getTrue() -> std::string
|
||||||
|
{
|
||||||
|
MockDb::_serializer_context_t printer = {};
|
||||||
|
return serialize(sqlpp::value(true), printer).str();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
auto getFalse() -> std::string
|
||||||
|
{
|
||||||
|
MockDb::_serializer_context_t printer = {};
|
||||||
|
return serialize(sqlpp::value(false), printer).str();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto toByteVector(const std::string& s) -> std::vector<std::uint8_t>
|
||||||
|
{
|
||||||
|
return std::vector<std::uint8_t>(s.begin(), s.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Blob(int, char* [])
|
||||||
|
{
|
||||||
|
const auto foo = test::TabFoo{};
|
||||||
|
// const auto bar = test::TabBar{};
|
||||||
|
|
||||||
|
// Unconditionally
|
||||||
|
compare(__LINE__, select(foo.book).from(foo).where(foo.book == toByteVector("john doe")),
|
||||||
|
"SELECT tab_foo.book FROM tab_foo WHERE (tab_foo.book=x'6A6F686E20646F65')");
|
||||||
|
|
||||||
|
std::array<uint8_t, 8> arr{{'j', 'o', 'h', 'n', ' ', 'd', 'o', 'e'}};
|
||||||
|
compare(__LINE__, select(foo.book).from(foo).where(foo.book == arr),
|
||||||
|
"SELECT tab_foo.book FROM tab_foo WHERE (tab_foo.book=x'6A6F686E20646F65')");
|
||||||
|
|
||||||
|
// Never
|
||||||
|
compare(__LINE__, where(sqlpp::value(false)), " WHERE " + getFalse());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2013-2016, Roland Bock
|
# Copyright (c) 2013-2017, Roland Bock
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -23,14 +23,15 @@
|
|||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
set(test_serializer_names
|
set(test_serializer_names
|
||||||
CustomQuery
|
|
||||||
As
|
As
|
||||||
|
Blob
|
||||||
|
CustomQuery
|
||||||
|
ForUpdate
|
||||||
From
|
From
|
||||||
In
|
In
|
||||||
Insert
|
Insert
|
||||||
TableAlias
|
TableAlias
|
||||||
Where
|
Where
|
||||||
ForUpdate
|
|
||||||
)
|
)
|
||||||
|
|
||||||
create_test_sourcelist(test_serializer_sources test_serializer_main.cpp ${test_serializer_names})
|
create_test_sourcelist(test_serializer_sources test_serializer_main.cpp ${test_serializer_names})
|
||||||
|
@ -71,10 +71,15 @@ int Insert(int, char* [])
|
|||||||
|
|
||||||
db(multi_insert);
|
db(multi_insert);
|
||||||
|
|
||||||
|
auto values=[&t](){
|
||||||
|
return std::make_tuple(t.gamma = true, t.delta = sqlpp::tvin(0));
|
||||||
|
};
|
||||||
|
|
||||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")));
|
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")));
|
||||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::null));
|
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::null));
|
||||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::default_value));
|
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::default_value));
|
||||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::tvin(0)));
|
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::tvin(0)));
|
||||||
|
db(insert_into(t).set(values()));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// an object to store internal Mock flags and values to validate in tests
|
// an object to store internal Mock flags and values to validate in tests
|
||||||
struct InternalMockData {
|
struct InternalMockData
|
||||||
|
{
|
||||||
sqlpp::isolation_level _last_isolation_level;
|
sqlpp::isolation_level _last_isolation_level;
|
||||||
sqlpp::isolation_level _default_isolation_level;
|
sqlpp::isolation_level _default_isolation_level;
|
||||||
};
|
};
|
||||||
@ -273,13 +274,16 @@ struct MockDbT : public sqlpp::connection
|
|||||||
}
|
}
|
||||||
|
|
||||||
void rollback_transaction(bool)
|
void rollback_transaction(bool)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void commit_transaction()
|
void commit_transaction()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void report_rollback_failure(std::string)
|
void report_rollback_failure(std::string)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// temporary data store to verify the expected results were produced
|
// temporary data store to verify the expected results were produced
|
||||||
InternalMockData _mock_data;
|
InternalMockData _mock_data;
|
||||||
@ -479,15 +483,22 @@ struct MockSizeDb : public sqlpp::connection
|
|||||||
}
|
}
|
||||||
|
|
||||||
void rollback_transaction(bool)
|
void rollback_transaction(bool)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void commit_transaction()
|
void commit_transaction()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void report_rollback_failure(std::string)
|
void report_rollback_failure(std::string)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// temporary data store to verify the expected results were produced
|
// temporary data store to verify the expected results were produced
|
||||||
InternalMockData _mock_data;
|
InternalMockData _mock_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using MockDb = MockDbT<false>;
|
||||||
|
using EnforceDb = MockDbT<true>;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,6 +52,8 @@ SQLPP_DECLARE_TABLE(
|
|||||||
(id , int , SQLPP_PRIMARY_KEY)
|
(id , int , SQLPP_PRIMARY_KEY)
|
||||||
(name , varchar(255), SQLPP_NOT_NULL )
|
(name , varchar(255), SQLPP_NOT_NULL )
|
||||||
(feature, int , SQLPP_NOT_NULL )
|
(feature, int , SQLPP_NOT_NULL )
|
||||||
|
(age , int_unsigned, SQLPP_NOT_NULL )
|
||||||
|
(level , real , SQLPP_NOT_NULL )
|
||||||
)
|
)
|
||||||
|
|
||||||
SQLPP_DECLARE_TABLE(
|
SQLPP_DECLARE_TABLE(
|
||||||
@ -76,14 +78,29 @@ int Ppgen(int, char* [])
|
|||||||
|
|
||||||
db(insert_into(f).default_values());
|
db(insert_into(f).default_values());
|
||||||
|
|
||||||
auto i = insert_into(p).columns(p.name, p.feature);
|
auto i = insert_into(p).columns(p.name, p.feature, p.age, p.level);
|
||||||
i.values.add(p.name = "Roland", p.feature = 1);
|
i.values.add(p.name = "Roland"
|
||||||
i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value);
|
, p.feature = 1
|
||||||
|
, p.age = static_cast<unsigned int>(32)
|
||||||
|
, p.level = 3.14);
|
||||||
|
i.values.add(p.name = "Zaphod"
|
||||||
|
, p.feature = sqlpp::default_value
|
||||||
|
, p.age = static_cast<unsigned int>(16)
|
||||||
|
, p.level = 3.14*2);
|
||||||
db(i);
|
db(i);
|
||||||
|
|
||||||
auto pi = db.prepare(insert_into(p).set(p.name = parameter(f.name), p.feature = parameter(p.feature)));
|
auto pi = db.prepare(
|
||||||
|
insert_into(p).set(
|
||||||
|
p.name = parameter(f.name)
|
||||||
|
,p.feature = parameter(p.feature)
|
||||||
|
,p.age = parameter(p.age)
|
||||||
|
,p.level = parameter(p.level)
|
||||||
|
)
|
||||||
|
);
|
||||||
pi.params.name = "likes java";
|
pi.params.name = "likes java";
|
||||||
pi.params.feature = true;
|
pi.params.feature = 2;
|
||||||
|
pi.params.age = 21;
|
||||||
|
pi.params.level = 3.14;
|
||||||
|
|
||||||
db(pi);
|
db(pi);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -97,9 +97,31 @@ namespace test
|
|||||||
};
|
};
|
||||||
using _traits = sqlpp::make_traits<sqlpp::bigint_unsigned, sqlpp::tag::can_be_null>;
|
using _traits = sqlpp::make_traits<sqlpp::bigint_unsigned, sqlpp::tag::can_be_null>;
|
||||||
};
|
};
|
||||||
|
struct Book
|
||||||
|
{
|
||||||
|
struct _alias_t
|
||||||
|
{
|
||||||
|
static constexpr const char _literal[] = "book";
|
||||||
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||||
|
template <typename T>
|
||||||
|
struct _member_t
|
||||||
|
{
|
||||||
|
T book;
|
||||||
|
T& operator()()
|
||||||
|
{
|
||||||
|
return book;
|
||||||
|
}
|
||||||
|
const T& operator()() const
|
||||||
|
{
|
||||||
|
return book;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
using _traits = sqlpp::make_traits<sqlpp::blob, sqlpp::tag::can_be_null>;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TabFoo : sqlpp::table_t<TabFoo, TabFoo_::Delta, TabFoo_::Epsilon, TabFoo_::Omega, TabFoo_::Psi>
|
struct TabFoo : sqlpp::table_t<TabFoo, TabFoo_::Delta, TabFoo_::Epsilon, TabFoo_::Omega, TabFoo_::Psi, TabFoo_::Book>
|
||||||
{
|
{
|
||||||
struct _alias_t
|
struct _alias_t
|
||||||
{
|
{
|
||||||
|
@ -63,11 +63,15 @@ int Update(int, char* [])
|
|||||||
|
|
||||||
db(u);
|
db(u);
|
||||||
|
|
||||||
|
auto values=[&t](){
|
||||||
|
return std::make_tuple(t.delta += t.alpha, t.beta = "no cake this time");
|
||||||
|
};
|
||||||
|
|
||||||
db(update(t).set(t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")).unconditionally());
|
db(update(t).set(t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")).unconditionally());
|
||||||
db(update(t).set(t.delta = sqlpp::null).unconditionally());
|
db(update(t).set(t.delta = sqlpp::null).unconditionally());
|
||||||
db(update(t).set(t.delta = sqlpp::default_value).unconditionally());
|
db(update(t).set(t.delta = sqlpp::default_value).unconditionally());
|
||||||
|
|
||||||
db(update(t).set(t.delta += t.alpha * 2, t.beta += " and cake").unconditionally());
|
db(update(t).set(t.delta += t.alpha * 2, t.beta += " and cake").unconditionally());
|
||||||
|
db(update(t).set(values()).unconditionally());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -49,5 +49,11 @@ int With(int, char* [])
|
|||||||
|
|
||||||
db(with(y)(select(y.alpha).from(y).unconditionally()));
|
db(with(y)(select(y.alpha).from(y).unconditionally()));
|
||||||
|
|
||||||
|
using ::sqlpp::alias::a;
|
||||||
|
using ::sqlpp::alias::b;
|
||||||
|
const auto c =
|
||||||
|
sqlpp::cte(b).as(select(t.alpha.as(a)).from(t).unconditionally().union_all(select(sqlpp::value(123).as(a))));
|
||||||
|
db(with(c)(select(all_of(c)).from(c).unconditionally()));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user