Skip to content

Commit e9f6f07

Browse files
committed
Merge branch 'release/0.58'
2 parents c789f91 + 60267ab commit e9f6f07

31 files changed

+413
-57
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ compiler:
1313

1414
env:
1515
- CONFIG=Release
16+
- CONFIG=Release TESTS_CXX_STD=17
1617
#- CONFIG=Debug
1718

1819
notifications:
@@ -37,7 +38,8 @@ before_script:
3738
sudo apt-get install python-pyparsing;
3839
fi
3940
- if [[ "$CXX" = "g++" && "$CONFIG" = "Debug" && "$TRAVIS_OS_NAME" = "linux" ]]; then export CXXFLAGS="--coverage"; fi
40-
- cmake .. -DCMAKE_BUILD_TYPE=$CONFIG -DCMAKE_PREFIX_PATH=$PWD/../date
41+
- if [[ -n "${TESTS_CXX_STD:-}" && "$TRAVIS_OS_NAME" = "osx" ]]; then ADD_OPTS="-DSQLPP11_TESTS_CXX_STD=$TESTS_CXX_STD"; fi
42+
- cmake .. -DCMAKE_BUILD_TYPE=$CONFIG -DCMAKE_PREFIX_PATH=$PWD/../date $ADD_OPTS
4143

4244
script:
4345
- cmake --build . --config $CONFIG

include/sqlpp11/char_sequence.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,19 @@ namespace sqlpp
5454
}
5555
};
5656

57-
template <std::size_t N, const char (&s)[N], typename T>
57+
template <std::size_t N, const char* s, typename T>
5858
struct make_char_sequence_impl;
5959

60-
template <std::size_t N, const char (&s)[N], std::size_t... i>
60+
template <std::size_t N, const char* s, std::size_t... i>
6161
struct make_char_sequence_impl<N, s, sqlpp::detail::index_sequence<i...>>
6262
{
6363
using type = char_sequence<s[i]...>;
6464
};
6565

66-
template <std::size_t N, const char (&Input)[N]>
66+
template <std::size_t N, const char* Input>
6767
using make_char_sequence =
6868
typename make_char_sequence_impl<N, Input, sqlpp::detail::make_index_sequence<N - 1>>::type;
69+
6970
} // namespace sqlpp
7071

7172
#endif

include/sqlpp11/data_types/blob/result_field.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <sqlpp11/data_types/blob/data_type.h>
3434
#include <sqlpp11/field_spec.h>
3535
#include <ostream>
36+
#include <string>
3637

3738
namespace sqlpp
3839
{
@@ -76,7 +77,9 @@ namespace sqlpp
7677
}
7778
else
7879
{
79-
return os << e.value();
80+
std::vector<uint8_t> value = e.value();
81+
std::string value_str(value.begin(), value.end());
82+
return os << value_str;
8083
}
8184
}
8285
} // namespace sqlpp

include/sqlpp11/data_types/text/operand.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
#include <string>
3131
#include <utility>
32+
#if __cplusplus >= 201703L
33+
#include <string_view>
34+
#endif
3235
#include <sqlpp11/type_traits.h>
3336
#include <sqlpp11/alias_operators.h>
3437
#include <sqlpp11/serializer.h>
@@ -50,6 +53,16 @@ namespace sqlpp
5053
text_operand(_value_t t) : _t(std::move(t))
5154
{
5255
}
56+
#if __cplusplus >= 201703L
57+
// allow construction from an std::string_view
58+
text_operand(std::string_view t) : _t(t)
59+
{
60+
}
61+
// additional const char* overload, required to disambiguate
62+
text_operand(const char* t) : _t(t)
63+
{
64+
}
65+
#endif
5366

5467
text_operand(const text_operand&) = default;
5568
text_operand(text_operand&&) = default;

include/sqlpp11/data_types/text/wrap_operand.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,26 @@
2828
#define SQLPP11_DATA_TYPES_TEXT_WRAP_OPERAND_H
2929

3030
#include <utility>
31+
#if __cplusplus >= 201703L
32+
#include <string_view>
33+
#endif
3134
#include <sqlpp11/type_traits.h>
3235
#include <sqlpp11/wrap_operand.h>
3336

3437
namespace sqlpp
3538
{
3639
struct text_operand;
3740

41+
#if __cplusplus >= 201703L
42+
using checked_type = std::string_view;
43+
#else
44+
using checked_type = std::string;
45+
#endif
46+
3847
template <typename T>
3948
struct wrap_operand<
4049
T,
41-
typename std::enable_if<std::is_convertible<T, std::string>::value and not is_result_field_t<T>::value>::type>
50+
typename std::enable_if<std::is_convertible<T, checked_type>::value and not is_result_field_t<T>::value>::type>
4251
{
4352
using type = text_operand;
4453
};

include/sqlpp11/group_by.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace sqlpp
102102
template <typename Expression>
103103
void _add_impl(Expression expression, const std::true_type& /*unused*/)
104104
{
105-
return _data._dynamic_expressions.emplace_back(expression);
105+
_data._dynamic_expressions.emplace_back(expression);
106106
}
107107

108108
template <typename Expression>

include/sqlpp11/having.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace sqlpp
103103
template <typename Expr>
104104
void _add_impl(Expr expression, const std::true_type& /*unused*/)
105105
{
106-
return _data._dynamic_expressions.emplace_back(expression);
106+
_data._dynamic_expressions.emplace_back(expression);
107107
}
108108

109109
template <typename Expr>

include/sqlpp11/insert_value.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <sqlpp11/default_value.h>
3131
#include <sqlpp11/null.h>
3232
#include <sqlpp11/tvin.h>
33+
#include <sqlpp11/value_or_null.h>
3334
#include <sqlpp11/type_traits.h>
3435
#include <sqlpp11/serializer.h>
3536
#include <sqlpp11/detail/type_set.h>
@@ -64,6 +65,7 @@ namespace sqlpp
6465
using _pure_value_t = typename value_type_of<Column>::_cpp_value_type;
6566
using _wrapped_value_t = wrap_operand_t<_pure_value_t>;
6667
using _tvin_t = tvin_t<_wrapped_value_t>;
68+
using _value_or_null_t = value_or_null_t<typename Column::_traits::_value_type>;
6769

6870
insert_value_t(rhs_wrap_t<_wrapped_value_t, _trivial_value_is_null> rhs)
6971
: _is_null(rhs._is_null()), _is_default(rhs._is_default()), _value(rhs._expr._t)
@@ -85,6 +87,11 @@ namespace sqlpp
8587
{
8688
}
8789

90+
insert_value_t(const rhs_wrap_t<_value_or_null_t, _trivial_value_is_null>& rhs)
91+
: _is_null(rhs._expr._is_null), _is_default(false), _value{rhs._expr._value}
92+
{
93+
}
94+
8895
insert_value_t(const insert_value_t&) = default;
8996
insert_value_t(insert_value_t&&) = default;
9097
insert_value_t& operator=(const insert_value_t&) = default;

include/sqlpp11/insert_value_list.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -627,17 +627,17 @@ namespace sqlpp
627627
context << " (";
628628
interpret_tuple(t._columns, ",", context);
629629
context << ")";
630-
context << " VALUES ";
631630
bool first = true;
632631
for (const auto& row : t._insert_values)
633632
{
634-
if (not first)
633+
if (first)
635634
{
636-
context << ',';
635+
context << " VALUES ";
636+
first = false;
637637
}
638638
else
639639
{
640-
first = false;
640+
context << ',';
641641
}
642642
context << '(';
643643
interpret_tuple(row, ",", context);
@@ -669,14 +669,18 @@ namespace sqlpp
669669
context << ',';
670670
}
671671
interpret_list(t._dynamic_columns, ',', context);
672-
context << ") VALUES(";
673-
interpret_tuple(t._values, ",", context);
674-
if (sizeof...(Assignments) and not t._dynamic_values.empty())
672+
context << ")";
673+
if (sizeof...(Assignments) or not t._dynamic_values.empty())
675674
{
676-
context << ',';
675+
context << " VALUES(";
676+
interpret_tuple(t._values, ",", context);
677+
if (sizeof...(Assignments) and not t._dynamic_values.empty())
678+
{
679+
context << ',';
680+
}
681+
interpret_list(t._dynamic_values, ',', context);
682+
context << ")";
677683
}
678-
interpret_list(t._dynamic_values, ',', context);
679-
context << ")";
680684
}
681685
return context;
682686
}

include/sqlpp11/order_by.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace sqlpp
100100
template <typename Expression>
101101
void _add_impl(Expression expression, const std::true_type& /*unused*/)
102102
{
103-
return _data._dynamic_expressions.emplace_back(expression);
103+
_data._dynamic_expressions.emplace_back(expression);
104104
}
105105

106106
template <typename Expression>

0 commit comments

Comments
 (0)