query parts progress
This commit is contained in:
+7
-4
@@ -18,13 +18,16 @@ std::string dialect::prepare_identifier(const column &col) const
|
||||
{
|
||||
std::string result;
|
||||
if (!col.is_function()) {
|
||||
result = prepare_identifier_string(col.name);
|
||||
if (!col.table.empty()) {
|
||||
result = prepare_identifier_string(col.table) + ".";
|
||||
}
|
||||
result += prepare_identifier_string(col.name);
|
||||
} else {
|
||||
result = sql_func_map_.at(col.function_) + "(" + col.name + ")";
|
||||
}
|
||||
if (!col.alias.empty()) {
|
||||
result += " AS " + col.alias;
|
||||
}
|
||||
// if (!col.alias.empty()) {
|
||||
// result += " AS " + col.alias;
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,8 @@ void query_compiler::visit(query_group_by_part &group_by_part)
|
||||
|
||||
void query_compiler::visit(query_order_by_part &order_by_part)
|
||||
{
|
||||
|
||||
query_.sql += " " + dialect_.token_at(dialect::token_t::ORDER_BY) +
|
||||
" " + dialect_.prepare_identifier(order_by_part.column());
|
||||
}
|
||||
|
||||
void query_compiler::visit(query_order_by_asc_part &order_by_asc_part)
|
||||
|
||||
@@ -96,8 +96,9 @@ query_group_by_intermediate query_where_intermediate::group_by(const std::string
|
||||
// return {connection_, builder_.group_by(name)};
|
||||
}
|
||||
|
||||
query_order_by_intermediate query_where_intermediate::order_by(const std::string &name)
|
||||
query_order_by_intermediate query_where_intermediate::order_by(const column &col)
|
||||
{
|
||||
data_.parts.push_back(std::make_unique<query_order_by_part>(col));
|
||||
return {connection_, data_};
|
||||
// return {connection_, builder_.order_by(name)};
|
||||
}
|
||||
@@ -114,8 +115,9 @@ query_group_by_intermediate query_on_intermediate::group_by(const std::string &n
|
||||
// return {connection_, builder_.group_by(name)};
|
||||
}
|
||||
|
||||
query_order_by_intermediate query_on_intermediate::order_by(const std::string &name)
|
||||
query_order_by_intermediate query_on_intermediate::order_by(const column &col)
|
||||
{
|
||||
data_.parts.push_back(std::make_unique<query_order_by_part>(col));
|
||||
return {connection_, data_};
|
||||
// return {connection_, builder_.order_by(name)};
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,3 +1,5 @@
|
||||
#include <utility>
|
||||
|
||||
#include "matador/sql/query_parts.hpp"
|
||||
#include "matador/sql/basic_condition.hpp"
|
||||
|
||||
@@ -81,10 +83,16 @@ void query_group_by_part::accept(query_part_visitor &visitor)
|
||||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
query_order_by_part::query_order_by_part(const std::string &table_name)
|
||||
: query_table_name_part(dialect::token_t::ORDER_BY, table_name)
|
||||
query_order_by_part::query_order_by_part(sql::column col)
|
||||
: query_part(dialect::token_t::ORDER_BY)
|
||||
, column_(std::move(col))
|
||||
{}
|
||||
|
||||
const sql::column &query_order_by_part::column() const
|
||||
{
|
||||
return column_;
|
||||
}
|
||||
|
||||
void query_order_by_part::accept(query_part_visitor &visitor)
|
||||
{
|
||||
visitor.visit(*this);
|
||||
|
||||
Reference in New Issue
Block a user