Skip to content

Commit 2c4efc0

Browse files
committed
minor fixes after review
1 parent a930369 commit 2c4efc0

2 files changed

Lines changed: 12 additions & 58 deletions

File tree

dev/statement_serializer.h

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -534,33 +534,15 @@ namespace sqlite_orm::internal {
534534
}
535535
};
536536

537-
template<>
538-
struct statement_serializer<window_ref_t, void> {
539-
using statement_type = window_ref_t;
540-
541-
template<class Ctx>
542-
SQLITE_ORM_STATIC_CALLOP std::string operator()(const statement_type& statement,
543-
const Ctx&) SQLITE_ORM_OR_CONST_CALLOP {
544-
return statement.name;
545-
}
546-
};
547-
548537
template<class Tuple, class Ctx>
549538
void serialize_over_arguments(std::stringstream& ss, const Tuple& arguments, const Ctx& context) {
550-
using args_tuple = std::decay_t<Tuple>;
551-
if constexpr (std::tuple_size_v<args_tuple> == 0) {
539+
if constexpr (std::tuple_size_v<Tuple> == 0) {
552540
ss << " OVER ()";
553-
} else if constexpr (std::tuple_size_v<args_tuple> == 1 &&
554-
std::is_same_v<std::tuple_element_t<0, args_tuple>, window_ref_t>) {
541+
} else if constexpr (std::tuple_size_v<Tuple> == 1 &&
542+
std::is_same_v<std::tuple_element_t<0, Tuple>, window_ref_t>) {
555543
ss << " OVER " << std::get<0>(arguments).name;
556544
} else {
557-
ss << " OVER (";
558-
std::string separator;
559-
iterate_tuple(arguments, [&ss, &context, &separator](auto& arg) {
560-
ss << separator << serialize(arg, context);
561-
separator = " ";
562-
});
563-
ss << ")";
545+
ss << " OVER (" << streaming_actions_tuple(arguments, context) << ")";
564546
}
565547
}
566548

@@ -600,13 +582,8 @@ namespace sqlite_orm::internal {
600582
SQLITE_ORM_STATIC_CALLOP std::string operator()(const statement_type& statement,
601583
const Ctx& context) SQLITE_ORM_OR_CONST_CALLOP {
602584
std::stringstream ss;
603-
ss << "WINDOW " << statement.name << " AS (";
604-
std::string separator;
605-
iterate_tuple(statement.arguments, [&ss, &context, &separator](auto& arg) {
606-
ss << separator << serialize(arg, context);
607-
separator = " ";
608-
});
609-
ss << ")";
585+
ss << "WINDOW " << statement.name << " AS (" << streaming_actions_tuple(statement.arguments, context)
586+
<< ")";
610587
return ss.str();
611588
}
612589
};

include/sqlite_orm/sqlite_orm.h

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22194,33 +22194,15 @@ namespace sqlite_orm::internal {
2219422194
}
2219522195
};
2219622196

22197-
template<>
22198-
struct statement_serializer<window_ref_t, void> {
22199-
using statement_type = window_ref_t;
22200-
22201-
template<class Ctx>
22202-
SQLITE_ORM_STATIC_CALLOP std::string operator()(const statement_type& statement,
22203-
const Ctx&) SQLITE_ORM_OR_CONST_CALLOP {
22204-
return statement.name;
22205-
}
22206-
};
22207-
2220822197
template<class Tuple, class Ctx>
2220922198
void serialize_over_arguments(std::stringstream& ss, const Tuple& arguments, const Ctx& context) {
22210-
using args_tuple = std::decay_t<Tuple>;
22211-
if constexpr (std::tuple_size_v<args_tuple> == 0) {
22199+
if constexpr (std::tuple_size_v<Tuple> == 0) {
2221222200
ss << " OVER ()";
22213-
} else if constexpr (std::tuple_size_v<args_tuple> == 1 &&
22214-
std::is_same_v<std::tuple_element_t<0, args_tuple>, window_ref_t>) {
22201+
} else if constexpr (std::tuple_size_v<Tuple> == 1 &&
22202+
std::is_same_v<std::tuple_element_t<0, Tuple>, window_ref_t>) {
2221522203
ss << " OVER " << std::get<0>(arguments).name;
2221622204
} else {
22217-
ss << " OVER (";
22218-
std::string separator;
22219-
iterate_tuple(arguments, [&ss, &context, &separator](auto& arg) {
22220-
ss << separator << serialize(arg, context);
22221-
separator = " ";
22222-
});
22223-
ss << ")";
22205+
ss << " OVER (" << streaming_actions_tuple(arguments, context) << ")";
2222422206
}
2222522207
}
2222622208

@@ -22260,13 +22242,8 @@ namespace sqlite_orm::internal {
2226022242
SQLITE_ORM_STATIC_CALLOP std::string operator()(const statement_type& statement,
2226122243
const Ctx& context) SQLITE_ORM_OR_CONST_CALLOP {
2226222244
std::stringstream ss;
22263-
ss << "WINDOW " << statement.name << " AS (";
22264-
std::string separator;
22265-
iterate_tuple(statement.arguments, [&ss, &context, &separator](auto& arg) {
22266-
ss << separator << serialize(arg, context);
22267-
separator = " ";
22268-
});
22269-
ss << ")";
22245+
ss << "WINDOW " << statement.name << " AS (" << streaming_actions_tuple(statement.arguments, context)
22246+
<< ")";
2227022247
return ss.str();
2227122248
}
2227222249
};

0 commit comments

Comments
 (0)