Skip to content

Commit 92d95b9

Browse files
authored
Merge pull request #1401 from fnc12/circumvent_triple_layered_alias_template
Avoided triple-layered alias template expressions
2 parents cfc1095 + 9ab6712 commit 92d95b9

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

dev/storage_impl.h

+8-11
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,15 @@ namespace sqlite_orm {
7070
constexpr decltype(auto) materialize_column_pointer(const DBOs&,
7171
const column_pointer<Moniker, alias_holder<ColAlias>>&) {
7272
using table_type = storage_pick_table_t<Moniker, DBOs>;
73-
using cte_mapper_type = cte_mapper_type_t<table_type>;
73+
using cte_colrefs_tuple = typename cte_mapper_type_t<table_type>::final_colrefs_tuple;
74+
using cte_fields_type = typename cte_mapper_type_t<table_type>::fields_type;
7475

7576
// lookup ColAlias in the final column references
76-
using colalias_index =
77-
find_tuple_type<typename cte_mapper_type::final_colrefs_tuple, alias_holder<ColAlias>>;
78-
static_assert(colalias_index::value < std::tuple_size_v<typename cte_mapper_type::final_colrefs_tuple>,
77+
using colalias_index = find_tuple_type<cte_colrefs_tuple, alias_holder<ColAlias>>;
78+
static_assert(colalias_index::value < std::tuple_size_v<cte_colrefs_tuple>,
7979
"No such column mapped into the CTE.");
8080

81-
return &aliased_field<
82-
ColAlias,
83-
std::tuple_element_t<colalias_index::value, typename cte_mapper_type::fields_type>>::field;
81+
return &aliased_field<ColAlias, std::tuple_element_t<colalias_index::value, cte_fields_type>>::field;
8482
}
8583
#endif
8684

@@ -104,14 +102,13 @@ namespace sqlite_orm {
104102
constexpr decltype(auto) find_column_name(const DBOs& dboObjects,
105103
const column_pointer<Moniker, alias_holder<ColAlias>>&) {
106104
using table_type = storage_pick_table_t<Moniker, DBOs>;
107-
using cte_mapper_type = cte_mapper_type_t<table_type>;
105+
using cte_colrefs_tuple = typename cte_mapper_type_t<table_type>::final_colrefs_tuple;
108106
using column_index_sequence = filter_tuple_sequence_t<elements_type_t<table_type>, is_column>;
109107

110108
// note: even though the columns contain the [`aliased_field<>::*`] we perform the lookup using the column references.
111109
// lookup ColAlias in the final column references
112-
using colalias_index =
113-
find_tuple_type<typename cte_mapper_type::final_colrefs_tuple, alias_holder<ColAlias>>;
114-
static_assert(colalias_index::value < std::tuple_size_v<typename cte_mapper_type::final_colrefs_tuple>,
110+
using colalias_index = find_tuple_type<cte_colrefs_tuple, alias_holder<ColAlias>>;
111+
static_assert(colalias_index::value < std::tuple_size_v<cte_colrefs_tuple>,
115112
"No such column mapped into the CTE.");
116113

117114
// note: we could "materialize" the alias to an `aliased_field<>::*` and use the regular `table_t<>::find_column_name()` mechanism;

include/sqlite_orm/sqlite_orm.h

+8-11
Original file line numberDiff line numberDiff line change
@@ -12663,17 +12663,15 @@ namespace sqlite_orm {
1266312663
constexpr decltype(auto) materialize_column_pointer(const DBOs&,
1266412664
const column_pointer<Moniker, alias_holder<ColAlias>>&) {
1266512665
using table_type = storage_pick_table_t<Moniker, DBOs>;
12666-
using cte_mapper_type = cte_mapper_type_t<table_type>;
12666+
using cte_colrefs_tuple = typename cte_mapper_type_t<table_type>::final_colrefs_tuple;
12667+
using cte_fields_type = typename cte_mapper_type_t<table_type>::fields_type;
1266712668

1266812669
// lookup ColAlias in the final column references
12669-
using colalias_index =
12670-
find_tuple_type<typename cte_mapper_type::final_colrefs_tuple, alias_holder<ColAlias>>;
12671-
static_assert(colalias_index::value < std::tuple_size_v<typename cte_mapper_type::final_colrefs_tuple>,
12670+
using colalias_index = find_tuple_type<cte_colrefs_tuple, alias_holder<ColAlias>>;
12671+
static_assert(colalias_index::value < std::tuple_size_v<cte_colrefs_tuple>,
1267212672
"No such column mapped into the CTE.");
1267312673

12674-
return &aliased_field<
12675-
ColAlias,
12676-
std::tuple_element_t<colalias_index::value, typename cte_mapper_type::fields_type>>::field;
12674+
return &aliased_field<ColAlias, std::tuple_element_t<colalias_index::value, cte_fields_type>>::field;
1267712675
}
1267812676
#endif
1267912677

@@ -12697,14 +12695,13 @@ namespace sqlite_orm {
1269712695
constexpr decltype(auto) find_column_name(const DBOs& dboObjects,
1269812696
const column_pointer<Moniker, alias_holder<ColAlias>>&) {
1269912697
using table_type = storage_pick_table_t<Moniker, DBOs>;
12700-
using cte_mapper_type = cte_mapper_type_t<table_type>;
12698+
using cte_colrefs_tuple = typename cte_mapper_type_t<table_type>::final_colrefs_tuple;
1270112699
using column_index_sequence = filter_tuple_sequence_t<elements_type_t<table_type>, is_column>;
1270212700

1270312701
// note: even though the columns contain the [`aliased_field<>::*`] we perform the lookup using the column references.
1270412702
// lookup ColAlias in the final column references
12705-
using colalias_index =
12706-
find_tuple_type<typename cte_mapper_type::final_colrefs_tuple, alias_holder<ColAlias>>;
12707-
static_assert(colalias_index::value < std::tuple_size_v<typename cte_mapper_type::final_colrefs_tuple>,
12703+
using colalias_index = find_tuple_type<cte_colrefs_tuple, alias_holder<ColAlias>>;
12704+
static_assert(colalias_index::value < std::tuple_size_v<cte_colrefs_tuple>,
1270812705
"No such column mapped into the CTE.");
1270912706

1271012707
// note: we could "materialize" the alias to an `aliased_field<>::*` and use the regular `table_t<>::find_column_name()` mechanism;

0 commit comments

Comments
 (0)