rename record_printer to RecordPrinter
This commit is contained in:
parent
caacdfa34a
commit
60f03246dc
|
|
@ -18,7 +18,7 @@
|
||||||
#include "models/shipment.hpp"
|
#include "models/shipment.hpp"
|
||||||
#include "models/model_metas.hpp"
|
#include "models/model_metas.hpp"
|
||||||
|
|
||||||
#include "../test/utils/record_printer.hpp"
|
#include "../test/utils/RecordPrinter.hpp"
|
||||||
|
|
||||||
using namespace matador::object;
|
using namespace matador::object;
|
||||||
using namespace matador::query;
|
using namespace matador::query;
|
||||||
|
|
@ -633,7 +633,7 @@ TEST_CASE_METHOD(QueryFixture, "Test load entity with eager has many relation",
|
||||||
|
|
||||||
REQUIRE(pkgs.is_ok());
|
REQUIRE(pkgs.is_ok());
|
||||||
|
|
||||||
record_printer printer(std::cout);
|
RecordPrinter printer(std::cout);
|
||||||
printer.print(*pkgs);
|
printer.print(*pkgs);
|
||||||
|
|
||||||
auto shipment_records = select({SHIPMENT.tracking_number, SHIPMENT.id, PACKAGE.weight, PACKAGE.weight})
|
auto shipment_records = select({SHIPMENT.tracking_number, SHIPMENT.id, PACKAGE.weight, PACKAGE.weight})
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "record_printer.hpp"
|
#include "RecordPrinter.hpp"
|
||||||
|
|
||||||
#include "matador/utils/basic_types.hpp"
|
#include "matador/utils/basic_types.hpp"
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
namespace matador::test {
|
namespace matador::test {
|
||||||
record_printer::record_printer(std::ostream &os)
|
RecordPrinter::RecordPrinter(std::ostream &os)
|
||||||
: os_(os) {
|
: os_(os) {
|
||||||
type_widths_ = {
|
type_widths_ = {
|
||||||
{utils::basic_type::Int8, 4},
|
{utils::basic_type::Int8, 4},
|
||||||
|
|
@ -32,7 +32,7 @@ record_printer::record_printer(std::ostream &os)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void record_printer::print_header(const sql::record &rec) const {
|
void RecordPrinter::print_header(const sql::record &rec) const {
|
||||||
for (const auto &f: rec.columns()) {
|
for (const auto &f: rec.columns()) {
|
||||||
os_ << std::left << std::setw(width(f)) << f.name() << " ";
|
os_ << std::left << std::setw(width(f)) << f.name() << " ";
|
||||||
}
|
}
|
||||||
|
|
@ -44,14 +44,14 @@ void record_printer::print_header(const sql::record &rec) const {
|
||||||
os_ << "\n";
|
os_ << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void record_printer::print(const sql::record &rec) const {
|
void RecordPrinter::print(const sql::record &rec) const {
|
||||||
for (const auto &f: rec.columns()) {
|
for (const auto &f: rec.columns()) {
|
||||||
os_ << std::left << std::setw(width(f)) << f.str() << " ";
|
os_ << std::left << std::setw(width(f)) << f.str() << " ";
|
||||||
}
|
}
|
||||||
os_ << "\n";
|
os_ << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int record_printer::width(const sql::field &f) {
|
int RecordPrinter::width(const sql::field &f) {
|
||||||
// If it's a varchar/string and has a defined size, use it if it's reasonable,
|
// If it's a varchar/string and has a defined size, use it if it's reasonable,
|
||||||
// otherwise fall back to type defaults.
|
// otherwise fall back to type defaults.
|
||||||
if ((f.is_varchar() || f.is_string()) && f.size() > 0 && f.size() < 100) {
|
if ((f.is_varchar() || f.is_string()) && f.size() > 0 && f.size() < 100) {
|
||||||
|
|
@ -12,9 +12,9 @@ class record;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace matador::test {
|
namespace matador::test {
|
||||||
class record_printer final {
|
class RecordPrinter final {
|
||||||
public:
|
public:
|
||||||
explicit record_printer(std::ostream &os);
|
explicit RecordPrinter(std::ostream &os);
|
||||||
|
|
||||||
void print_header(const sql::record &rec) const;
|
void print_header(const sql::record &rec) const;
|
||||||
void print(const sql::record &rec) const;
|
void print(const sql::record &rec) const;
|
||||||
Loading…
Reference in New Issue