Merge remote-tracking branch 'origin/main'
# Conflicts: # demo/main.cpp
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "matador/sql/noop_connection.hpp"
|
||||
#include "matador/sql/dialect_builder.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
+22
-16
@@ -7,23 +7,27 @@
|
||||
namespace matador::sql {
|
||||
|
||||
record::record(std::initializer_list<field> columns)
|
||||
: fields_(columns)
|
||||
{
|
||||
init();
|
||||
for (auto &&col :columns) {
|
||||
const auto it = fields_by_name_.emplace(col.name(), field_index_pair {col, fields_.size()});
|
||||
fields_.push_back(std::ref(it.first->second.first));
|
||||
}
|
||||
}
|
||||
|
||||
record::record(const std::vector<field> &columns)
|
||||
: fields_(columns)
|
||||
{
|
||||
init();
|
||||
for (auto &&col :columns) {
|
||||
const auto it = fields_by_name_.emplace(col.name(), field_index_pair {col, fields_.size()});
|
||||
fields_.push_back(std::ref(it.first->second.first));
|
||||
}
|
||||
}
|
||||
|
||||
record::record(const record &x)
|
||||
: fields_(x.fields_)
|
||||
: fields_by_name_(x.fields_by_name_)
|
||||
//, pk_index_(x.pk_index_)
|
||||
{
|
||||
for (auto& col : fields_) {
|
||||
add_to_map(col, col.index());
|
||||
for (auto& col : fields_by_name_) {
|
||||
fields_.push_back(std::ref(col.second.first));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,16 +37,16 @@ record &record::operator=(const record &x)
|
||||
return *this;
|
||||
}
|
||||
|
||||
fields_ = x.fields_;
|
||||
fields_by_name_.clear();
|
||||
fields_by_name_ = x.fields_by_name_;
|
||||
fields_.clear();
|
||||
// pk_index_ = x.pk_index_;
|
||||
for (auto& col : fields_) {
|
||||
add_to_map(col, col.index());
|
||||
for (auto& col : fields_by_name_) {
|
||||
fields_.push_back(std::ref(col.second.first));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::vector<field> &record::columns() const
|
||||
const std::vector<record::field_ref> &record::columns() const
|
||||
{
|
||||
return fields_;
|
||||
}
|
||||
@@ -63,7 +67,9 @@ const std::vector<field> &record::columns() const
|
||||
|
||||
const field &record::at(const column &col) const
|
||||
{
|
||||
return fields_by_name_.at(col.name).first;
|
||||
const auto &res = fields_by_name_.at(col.name);
|
||||
const auto &f = res.first;
|
||||
return f;
|
||||
}
|
||||
|
||||
const field &record::at(size_t index) const
|
||||
@@ -82,10 +88,10 @@ record::const_iterator record::find(const std::string &column_name) const {
|
||||
return it != fields_by_name_.end() ? fields_.begin() + it->second.second : fields_.end();
|
||||
}
|
||||
|
||||
void record::append(field col)
|
||||
void record::append(const field &col)
|
||||
{
|
||||
auto &ref = fields_.emplace_back(std::move(col));
|
||||
add_to_map(ref, fields_.size() - 1);
|
||||
const auto it = fields_by_name_.emplace(col.name(), field_index_pair {col, fields_.size()});
|
||||
fields_.push_back(std::ref(it.first->second.first));
|
||||
}
|
||||
|
||||
record::iterator record::begin()
|
||||
|
||||
Reference in New Issue
Block a user