Commit 9e6f1410 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

fix query tests

parent 4344dde6
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -42,9 +42,11 @@ Query::Query(const char* query_string, query::TableRepository* repo) {

void Query::execute() {
  for (const auto& stmt : statements_) {
    //target->addHeader(stmt->getColumns());
    //stmt->setTarget(target);
    //stmt->execute();
    auto target = new ResultList();
    target->addHeader(stmt->getColumns());
    stmt->setTarget(target);
    stmt->execute();
    results_.emplace_back(target);
  }
}

+1 −1
Original line number Diff line number Diff line
@@ -886,5 +886,5 @@ public:
int main() {
  fnordmetric::QueryTest test;
  test.run();
  //printf("all tests passed! :)\n");
  printf("all tests passed! :)\n");
}
+9 −5
Original line number Diff line number Diff line
@@ -15,11 +15,7 @@
namespace fnordmetric {
namespace query {

class AbstractResultList {

};

class ResultList : public AbstractResultList {
class ResultList : public RowSink {
public:
  ResultList() {}
  ResultList(const ResultList& copy) = delete;
@@ -58,6 +54,14 @@ public:
    rows_.back().push_back(value);
  }

  bool nextRow(query::SValue* row, int row_len) override {
    addRow();
    for (int i = 0; i < row_len; ++i) {
      addColumn(row[i].toString());
    }
    return true;
  }

  void debugPrint() const {
    std::vector<int> col_widths;
    int total_width = 0;