Skip to content

Commit cb39f45

Browse files
committed
Merge branch 'upstream/circumvent_triple_layered_alias_template' into upstream/connection_control
2 parents 8147850 + 9ab6712 commit cb39f45

2 files changed

Lines changed: 16 additions & 22 deletions

File tree

dev/storage_impl.h

Lines changed: 8 additions & 11 deletions
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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12696,17 +12696,15 @@ namespace sqlite_orm {
1269612696
constexpr decltype(auto) materialize_column_pointer(const DBOs&,
1269712697
const column_pointer<Moniker, alias_holder<ColAlias>>&) {
1269812698
using table_type = storage_pick_table_t<Moniker, DBOs>;
12699-
using cte_mapper_type = cte_mapper_type_t<table_type>;
12699+
using cte_colrefs_tuple = typename cte_mapper_type_t<table_type>::final_colrefs_tuple;
12700+
using cte_fields_type = typename cte_mapper_type_t<table_type>::fields_type;
1270012701

1270112702
// lookup ColAlias in the final column references
12702-
using colalias_index =
12703-
find_tuple_type<typename cte_mapper_type::final_colrefs_tuple, alias_holder<ColAlias>>;
12704-
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>,
1270512705
"No such column mapped into the CTE.");
1270612706

12707-
return &aliased_field<
12708-
ColAlias,
12709-
std::tuple_element_t<colalias_index::value, typename cte_mapper_type::fields_type>>::field;
12707+
return &aliased_field<ColAlias, std::tuple_element_t<colalias_index::value, cte_fields_type>>::field;
1271012708
}
1271112709
#endif
1271212710

@@ -12730,14 +12728,13 @@ namespace sqlite_orm {
1273012728
constexpr decltype(auto) find_column_name(const DBOs& dboObjects,
1273112729
const column_pointer<Moniker, alias_holder<ColAlias>>&) {
1273212730
using table_type = storage_pick_table_t<Moniker, DBOs>;
12733-
using cte_mapper_type = cte_mapper_type_t<table_type>;
12731+
using cte_colrefs_tuple = typename cte_mapper_type_t<table_type>::final_colrefs_tuple;
1273412732
using column_index_sequence = filter_tuple_sequence_t<elements_type_t<table_type>, is_column>;
1273512733

1273612734
// note: even though the columns contain the [`aliased_field<>::*`] we perform the lookup using the column references.
1273712735
// lookup ColAlias in the final column references
12738-
using colalias_index =
12739-
find_tuple_type<typename cte_mapper_type::final_colrefs_tuple, alias_holder<ColAlias>>;
12740-
static_assert(colalias_index::value < std::tuple_size_v<typename cte_mapper_type::final_colrefs_tuple>,
12736+
using colalias_index = find_tuple_type<cte_colrefs_tuple, alias_holder<ColAlias>>;
12737+
static_assert(colalias_index::value < std::tuple_size_v<cte_colrefs_tuple>,
1274112738
"No such column mapped into the CTE.");
1274212739

1274312740
// 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)