Skip to content

Commit d0462cd

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents e41c35a + ffd2bd8 commit d0462cd

File tree

14 files changed

+149
-169
lines changed

14 files changed

+149
-169
lines changed

dev/ast/upsert_clause.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#pragma once
22

3-
#include <tuple> // std::tuple, std::make_tuple
4-
#include <type_traits> // std::false_type, std::true_type
3+
#if SQLITE_VERSION_NUMBER >= 3024000
4+
#include <tuple> // std::tuple
55
#include <utility> // std::forward, std::move
6+
#endif
67

78
#include "../functional/cxx_type_traits_polyfill.h"
89

@@ -24,7 +25,7 @@ namespace sqlite_orm {
2425

2526
template<class... ActionsArgs>
2627
upsert_clause<args_tuple, std::tuple<ActionsArgs...>> do_update(ActionsArgs... actions) {
27-
return {std::move(this->args), {std::make_tuple(std::forward<ActionsArgs>(actions)...)}};
28+
return {std::move(this->args), {std::forward<ActionsArgs>(actions)...}};
2829
}
2930
};
3031

@@ -40,8 +41,13 @@ namespace sqlite_orm {
4041

4142
template<class T>
4243
using is_upsert_clause = polyfill::is_specialization_of<T, upsert_clause>;
44+
#else
45+
template<class T>
46+
struct is_upsert_clause : polyfill::bool_constant<false> {};
47+
#endif
4348
}
4449

50+
#if SQLITE_VERSION_NUMBER >= 3024000
4551
/**
4652
* ON CONFLICT upsert clause builder function.
4753
* @example

dev/ast_iterator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ namespace sqlite_orm {
105105
}
106106
};
107107

108-
template<class... TargetArgs, class... ActionsArgs>
109-
struct ast_iterator<upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>>, void> {
110-
using node_type = upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>>;
108+
template<class T>
109+
struct ast_iterator<T, match_if<is_upsert_clause, T>> {
110+
using node_type = T;
111111

112112
template<class L>
113113
void operator()(const node_type& expression, L& lambda) const {

dev/column_names_getter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ namespace sqlite_orm {
2121

2222
namespace internal {
2323

24-
template<class T, class I>
25-
std::string serialize(const T& t, const serializer_context<I>& context);
24+
template<class T, class DBOs>
25+
std::string serialize(const T&, const serializer_context<DBOs>&);
2626

2727
template<class T, class Ctx>
2828
std::vector<std::string>& collect_table_column_names(std::vector<std::string>& collectedExpressions,

dev/default_value_extractor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace sqlite_orm {
1010

1111
namespace internal {
1212

13-
template<class T, class I>
14-
std::string serialize(const T& t, const serializer_context<I>& context);
13+
template<class T, class DBOs>
14+
std::string serialize(const T&, const serializer_context<DBOs>&);
1515

1616
/**
1717
* Serialize default value of a column's default valu

dev/node_tuple.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ namespace sqlite_orm {
5454
using type = tuple_cat_t<args_tuple, expression_tuple>;
5555
};
5656

57-
template<class... TargetArgs, class... ActionsArgs>
58-
struct node_tuple<upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>>, void>
59-
: node_tuple<std::tuple<ActionsArgs...>> {};
57+
template<class T>
58+
struct node_tuple<T, match_if<is_upsert_clause, T>> : node_tuple<typename T::actions_tuple> {};
6059

6160
template<class... Args>
6261
struct node_tuple<set_t<Args...>, void> {

dev/serialize_result_type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ namespace sqlite_orm {
99
namespace internal {
1010
#ifdef SQLITE_ORM_STRING_VIEW_SUPPORTED
1111
using serialize_result_type = std::string_view;
12+
using serialize_arg_type = std::string_view;
1213
#else
1314
using serialize_result_type = std::string;
15+
using serialize_arg_type = const std::string&;
1416
#endif
1517
}
1618
}

dev/serializing_util.h

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,44 @@
66
#include <string>
77
#include <ostream>
88
#include <utility> // std::exchange, std::tuple_size
9-
#if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
10-
#include <string_view>
11-
#include <algorithm> // std::find
12-
#endif
139

1410
#include "functional/cxx_universal.h" // ::size_t
1511
#include "functional/cxx_type_traits_polyfill.h"
1612
#include "tuple_helper/tuple_iteration.h"
1713
#include "error_code.h"
1814
#include "serializer_context.h"
15+
#include "serialize_result_type.h"
1916
#include "util.h"
2017

2118
namespace sqlite_orm {
2219
namespace internal {
2320
template<class O>
2421
struct order_by_t;
2522

26-
template<class T, class I>
27-
std::string serialize(const T& t, const serializer_context<I>& context);
23+
template<class T, class DBOs>
24+
std::string serialize(const T&, const serializer_context<DBOs>&);
2825

2926
template<class T, class Ctx>
30-
std::string serialize_order_by(const T& t, const Ctx& context);
31-
32-
#if defined(SQLITE_ORM_CONCEPTS_SUPPORTED) && !defined(SQLITE_ORM_BROKEN_NONTEMPLATE_CONCEPTS)
33-
// optimized version when string_view's iterator range constructor is available
34-
template<class SFINAE = void>
35-
void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape)
36-
requires requires {
37-
std::string_view{str.cbegin(), str.cend()};
38-
}
39-
{
40-
for(std::string::const_iterator it = str.cbegin(), next; true; it = next + 1) {
41-
next = std::find(it, str.cend(), char2Escape);
42-
os << std::string_view{it, next};
43-
44-
if(next == str.cend()) [[likely]] {
27+
std::string serialize_order_by(const T&, const Ctx&);
28+
29+
inline void stream_sql_escaped(std::ostream& os, serialize_arg_type str, char char2Escape) {
30+
for(size_t offset = 0, next; true; offset = next + 1) {
31+
next = str.find(char2Escape, offset);
32+
33+
if(next == str.npos) {
34+
os.write(str.data() + offset, str.size() - offset);
4535
break;
4636
}
47-
os << std::string(2, char2Escape);
48-
}
49-
}
5037

51-
template<class SFINAE = void>
52-
#endif
53-
inline void stream_sql_escaped(std::ostream& os, const std::string& str, char char2Escape) {
54-
if(str.find(char2Escape) == str.npos) {
55-
os << str;
56-
} else {
57-
for(char c: str) {
58-
if(c == char2Escape) {
59-
os << char2Escape;
60-
}
61-
os << c;
62-
}
38+
os.write(str.data() + offset, next - offset + 1);
39+
os.write(&char2Escape, 1);
6340
}
6441
}
6542

6643
inline void stream_identifier(std::ostream& ss,
67-
const std::string& qualifier,
68-
const std::string& identifier,
69-
const std::string& alias) {
44+
serialize_arg_type qualifier,
45+
serialize_arg_type identifier,
46+
serialize_arg_type alias) {
7047
constexpr char quoteChar = '"';
7148
constexpr char qualified[] = {quoteChar, '.', '\0'};
7249
constexpr char aliased[] = {' ', quoteChar, '\0'};
@@ -92,11 +69,11 @@ namespace sqlite_orm {
9269
}
9370

9471
inline void stream_identifier(std::ostream& ss, const std::string& identifier, const std::string& alias) {
95-
return stream_identifier(ss, std::string{}, identifier, alias);
72+
return stream_identifier(ss, "", identifier, alias);
9673
}
9774

9875
inline void stream_identifier(std::ostream& ss, const std::string& identifier) {
99-
return stream_identifier(ss, std::string{}, identifier, std::string{});
76+
return stream_identifier(ss, "", identifier, "");
10077
}
10178

10279
template<typename Tpl, size_t... Is>

dev/statement_serializer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ namespace sqlite_orm {
5151
template<class T, class SFINAE = void>
5252
struct statement_serializer;
5353

54-
template<class T, class I>
55-
std::string serialize(const T& t, const serializer_context<I>& context) {
54+
template<class T, class DBOs>
55+
std::string serialize(const T& t, const serializer_context<DBOs>& context) {
5656
statement_serializer<T> serializer;
5757
return serializer(t, context);
5858
}
@@ -224,9 +224,9 @@ namespace sqlite_orm {
224224
}
225225
};
226226

227-
template<class... TargetArgs, class... ActionsArgs>
228-
struct statement_serializer<upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>>, void> {
229-
using statement_type = upsert_clause<std::tuple<TargetArgs...>, std::tuple<ActionsArgs...>>;
227+
template<class T>
228+
struct statement_serializer<T, match_if<is_upsert_clause, T>> {
229+
using statement_type = T;
230230

231231
template<class Ctx>
232232
std::string operator()(const statement_type& statement, const Ctx& context) const {

dev/table.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ namespace sqlite_orm {
110110
constexpr size_t opIndex = first_index_sequence_value(generated_op_index_sequence{});
111111
result = &get<opIndex>(column.constraints).storage;
112112
});
113+
#else
114+
(void)name;
113115
#endif
114116
return result;
115117
}

0 commit comments

Comments
 (0)