query/source/orm/sql/query_result.cpp

35 lines
913 B
C++

#include "matador/sql/query_result.hpp"
#include "matador/sql/record.hpp"
#include "matador/sql/internal/query_result_impl.hpp"
namespace matador::sql::detail {
field_type determine_field_type(const utils::constraints c) {
if (is_constraint_set(c, utils::constraints::FOREIGN_KEY)) {
return field_type::ForeignKey;
}
if (is_constraint_set(c, utils::constraints::PRIMARY_KEY)) {
return field_type::PrimaryKey;
}
return field_type::Attribute;
}
template<>
record *create_prototype<record>(const std::vector<object::attribute_definition> &prototype) {
auto result = std::make_unique<record>();
for (const auto &col: prototype) {
result->append({
col.name(),
col.type(),
determine_field_type(col.attributes().options()),
col.attributes().size(),
col.index()
});
}
return result.release();
}
} // namespace matador::sql