fixed some repository-related tests
This commit is contained in:
@@ -53,6 +53,15 @@ bool repository::contains( const std::type_index& index ) const {
|
||||
return nodes_by_type_.count(index) > 0;
|
||||
}
|
||||
|
||||
utils::result<basic_object_info_ref, utils::error> repository::basic_info( const std::string& name ) const {
|
||||
auto result = find_node(name);
|
||||
if (!result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
|
||||
return utils::ok(basic_object_info_ref{result.value()->info()});
|
||||
}
|
||||
|
||||
utils::result<std::shared_ptr<attribute_definition>, utils::error> repository::reference_column(const std::type_index &type_index) const {
|
||||
const auto result = find_node(type_index);
|
||||
if (result) {
|
||||
|
||||
@@ -18,6 +18,19 @@ column_generator::column_generator(std::vector<column> &column_infos,
|
||||
seen_tables.insert(table_name);
|
||||
}
|
||||
|
||||
std::vector<column> column_generator::generate( const object::repository& scm, const std::string& name, bool force_lazy ) {
|
||||
const auto info = scm.basic_info(name);
|
||||
if (!info) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<column> columns;
|
||||
for (const auto attr : info.value().get().definition()) {
|
||||
columns.push_back(column{attr.name()});
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
void column_generator::on_revision(const char *id, unsigned long long int &)
|
||||
{
|
||||
if (has_many_to_many_) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <thread>
|
||||
|
||||
namespace matador::sql {
|
||||
identifiable_connection::identifiable_connection(const size_t id, connection conn)
|
||||
identifiable_connection::identifiable_connection(const size_t id, connection &&conn)
|
||||
: id(id)
|
||||
, conn(std::move(conn)){}
|
||||
|
||||
@@ -57,7 +57,9 @@ connection_pool::connection_pool(const std::string& dns, size_t count)
|
||||
: info_(connection_info::parse(dns)) {
|
||||
connection_repo_.reserve(count);
|
||||
while (count) {
|
||||
connection_repo_.emplace_back(count, connection{info_});
|
||||
connection c(info_);
|
||||
connection_repo_.emplace_back(count, std::move(c));
|
||||
// connection_repo_.emplace_back(count, connection{info_});
|
||||
auto &conn = connection_repo_.back();
|
||||
idle_connections_.emplace(conn.id, &conn);
|
||||
// Todo: handle result
|
||||
|
||||
Reference in New Issue
Block a user