fixed PostgreSQL tests
This commit is contained in:
+12
-24
@@ -35,8 +35,7 @@ field &field::operator=(field &&x) noexcept {
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::string &field::name() const
|
||||
{
|
||||
const std::string &field::name() const {
|
||||
return name_;
|
||||
}
|
||||
|
||||
@@ -44,59 +43,48 @@ utils::constraints field::type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
size_t field::size() const
|
||||
{
|
||||
size_t field::size() const {
|
||||
return value_.size();
|
||||
}
|
||||
|
||||
int field::index() const
|
||||
{
|
||||
int field::index() const {
|
||||
return index_;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const field &col)
|
||||
{
|
||||
std::ostream &operator<<(std::ostream &out, const field &col) {
|
||||
out << col.str();
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string field::str() const
|
||||
{
|
||||
std::string field::str() const {
|
||||
return as<std::string>().value_or("");
|
||||
}
|
||||
|
||||
bool field::is_integer() const
|
||||
{
|
||||
bool field::is_integer() const {
|
||||
return value_.is_integer();
|
||||
}
|
||||
|
||||
bool field::is_floating_point() const
|
||||
{
|
||||
bool field::is_floating_point() const {
|
||||
return value_.is_floating_point();
|
||||
}
|
||||
|
||||
bool field::is_bool() const
|
||||
{
|
||||
bool field::is_bool() const {
|
||||
return value_.is_bool();
|
||||
}
|
||||
|
||||
bool field::is_string() const
|
||||
{
|
||||
bool field::is_string() const {
|
||||
return value_.is_string();
|
||||
}
|
||||
|
||||
bool field::is_varchar() const
|
||||
{
|
||||
bool field::is_varchar() const {
|
||||
return value_.is_varchar();
|
||||
}
|
||||
|
||||
bool field::is_blob() const
|
||||
{
|
||||
bool field::is_blob() const {
|
||||
return value_.is_blob();
|
||||
}
|
||||
|
||||
bool field::is_null() const
|
||||
{
|
||||
bool field::is_null() const {
|
||||
return value_.is_null();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,16 +5,14 @@
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
record::record(std::initializer_list<field> columns)
|
||||
{
|
||||
record::record(const std::initializer_list<field> columns) {
|
||||
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)
|
||||
{
|
||||
record::record(const std::vector<field> &columns) {
|
||||
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));
|
||||
@@ -23,7 +21,6 @@ record::record(const std::vector<field> &columns)
|
||||
|
||||
record::record(const record &x)
|
||||
: fields_by_name_(x.fields_by_name_)
|
||||
//, pk_index_(x.pk_index_)
|
||||
{
|
||||
for (auto& col : x.fields_) {
|
||||
auto &it = fields_by_name_.at(col.get().name());
|
||||
@@ -47,25 +44,10 @@ record &record::operator=(const record &x)
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::vector<record::field_ref> &record::columns() const
|
||||
{
|
||||
const std::vector<record::field_ref> &record::columns() const {
|
||||
return fields_;
|
||||
}
|
||||
|
||||
//bool record::has_primary_key() const
|
||||
//{
|
||||
// return pk_index_ > -1;
|
||||
//}
|
||||
//
|
||||
//std::optional<field> record::primary_key() const
|
||||
//{
|
||||
// if (!has_primary_key()) {
|
||||
// return std::nullopt;
|
||||
// }
|
||||
//
|
||||
// return columns_[pk_index_];
|
||||
//}
|
||||
|
||||
const field &record::at(const std::string &name) const {
|
||||
const auto &res = fields_by_name_.at(name);
|
||||
const auto &f = res.first;
|
||||
@@ -88,8 +70,7 @@ 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(const field &col)
|
||||
{
|
||||
void record::append(const field &col) {
|
||||
const auto it = fields_by_name_.emplace(col.name(), field_index_pair {col, fields_.size()});
|
||||
fields_.push_back(std::ref(it.first->second.first));
|
||||
}
|
||||
@@ -140,13 +121,6 @@ void record::clear()
|
||||
fields_by_name_.clear();
|
||||
}
|
||||
|
||||
//bool record::unknown() const
|
||||
//{
|
||||
// return std::all_of(std::begin(columns_), std::end(columns_), [](const auto &col) {
|
||||
// return col.type() == data_type_t::type_unknown;
|
||||
// });
|
||||
//}
|
||||
|
||||
void record::init()
|
||||
{
|
||||
size_t index{0};
|
||||
|
||||
Reference in New Issue
Block a user