fixed column generator test

This commit is contained in:
2025-02-11 21:48:47 +01:00
parent 1d83abcb1b
commit 55f9f8cf67
3 changed files with 53 additions and 35 deletions
+29 -20
View File
@@ -27,7 +27,7 @@ public:
~column_generator() = default;
template < class Type >
static std::vector<column> generate(const object::schema &scm, bool force_lazy = false)
static std::vector<column> generate(const object::schema &scm, const bool force_lazy = false)
{
const auto info = scm.info<Type>();
if (!info) {
@@ -36,7 +36,7 @@ public:
std::vector<column> columns;
column_generator gen(columns, scm, info.value().get().name(), force_lazy);
Type obj;
matador::access::process(gen, obj);
access::process(gen, obj);
return std::move(columns);
}
@@ -61,10 +61,14 @@ public:
if (!info) {
return;
}
table_name_stack_.push(info.value().get().name());
typename Pointer::value_type obj;
matador::access::process(*this, obj);
table_name_stack_.pop();
if (seen_tables.count(info->get().name()) == 0) {
auto it = seen_tables.insert(info->get().name()).first;
table_name_stack_.push(info->get().name());
typename Pointer::value_type obj;
access::process(*this, obj);
table_name_stack_.pop();
seen_tables.erase(it);
}
}
}
template<class Pointer>
@@ -77,10 +81,14 @@ public:
if (!info) {
return;
}
table_name_stack_.push(info.value().get().name());
typename Pointer::value_type obj;
matador::access::process(*this, obj);
table_name_stack_.pop();
if (seen_tables.count(info->get().name()) == 0) {
auto it = seen_tables.insert(info->get().name()).first;
table_name_stack_.push(info.value().get().name());
typename Pointer::value_type obj;
access::process(*this, obj);
table_name_stack_.pop();
seen_tables.erase(it);
}
}
}
template<class ContainerType>
@@ -94,21 +102,21 @@ public:
return;
}
table_name_stack_.push(info.value().get().name());
typename ContainerType::value_type::value_type obj;
matador::access::process(*this, obj);
table_name_stack_.pop();
if (seen_tables.count(info->get().name()) == 0) {
auto it = seen_tables.insert(info->get().name()).first;
table_name_stack_.push(info.value().get().name());
typename ContainerType::value_type::value_type obj;
access::process(*this, obj);
table_name_stack_.pop();
seen_tables.erase(it);
}
}
template<class ContainerType>
void on_has_many_to_many(const char *id, ContainerType &c, const char *join_column, const char *inverse_join_column, const utils::foreign_attributes &attr)
{
}
static void on_has_many_to_many(const char *id, ContainerType &c, const char *join_column, const char *inverse_join_column, const utils::foreign_attributes &attr) {}
template<class ContainerType>
void on_has_many_to_many(const char *id, ContainerType &c, const utils::foreign_attributes &attr)
{
}
static void on_has_many_to_many(const char *id, ContainerType &c, const utils::foreign_attributes &attr) {}
private:
void push(const std::string &column_name);
@@ -116,6 +124,7 @@ private:
private:
std::stack<std::string> table_name_stack_;
std::vector<column> &column_infos_;
std::unordered_set<std::string> seen_tables;
const object::schema &table_schema_;
int column_index{0};
bool force_lazy_{false};