query parts progress
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
namespace matador::sql {
|
||||
|
||||
query_compiler::query_compiler(const sql::dialect &d)
|
||||
: dialect_(d)
|
||||
: dialect_(d)
|
||||
{}
|
||||
|
||||
query_context query_compiler::compile(const query_data *data)
|
||||
@@ -53,28 +53,34 @@ void query_compiler::visit(query_from_part &from_part)
|
||||
if (dialect_.default_schema_name().empty()) {
|
||||
query_.sql += " " + dialect_.token_at(dialect::token_t::FROM) +
|
||||
" " + dialect_.prepare_identifier(from_part.table().name) +
|
||||
(from_part.table().alias.empty() ? "" : " AS " + dialect_.prepare_identifier(from_part.table().alias));
|
||||
(from_part.table().alias.empty() ? "" : " AS " +
|
||||
dialect_.prepare_identifier(from_part.table().alias));
|
||||
} else {
|
||||
query_.sql += " " + dialect_.token_at(dialect::token_t::FROM) +
|
||||
" " + dialect_.prepare_identifier(dialect_.default_schema_name()) +
|
||||
"." + dialect_.prepare_identifier(from_part.table().name) +
|
||||
(from_part.table().alias.empty() ? "" : " AS " + dialect_.prepare_identifier(from_part.table().alias));
|
||||
(from_part.table().alias.empty() ? "" : " AS " +
|
||||
dialect_.prepare_identifier(from_part.table().alias));
|
||||
}
|
||||
}
|
||||
|
||||
void query_compiler::visit(query_join_part &join_part)
|
||||
{
|
||||
|
||||
query_.sql += " " + dialect_.token_at(dialect::token_t::JOIN) +
|
||||
" " + dialect_.prepare_identifier(join_part.table().name) +
|
||||
(join_part.table().alias.empty() ? "" : " AS " + dialect_.prepare_identifier(join_part.table().alias));
|
||||
}
|
||||
|
||||
void query_compiler::visit(query_on_part &on_part)
|
||||
{
|
||||
|
||||
query_.sql += " " + dialect_.token_at(dialect::token_t::ON) +
|
||||
" " + on_part.condition().evaluate(const_cast<dialect &>(dialect_), query_);
|
||||
}
|
||||
|
||||
void query_compiler::visit(query_where_part &where_part)
|
||||
{
|
||||
|
||||
query_.sql += " " + dialect_.token_at(dialect::token_t::WHERE) +
|
||||
" " + where_part.condition().evaluate(const_cast<dialect &>(dialect_), query_);
|
||||
}
|
||||
|
||||
void query_compiler::visit(query_group_by_part &group_by_part)
|
||||
|
||||
@@ -108,12 +108,6 @@ query_join_intermediate query_on_intermediate::join(const std::string &join_tabl
|
||||
// return {connection_, builder_.join(join_table_name, join_type_t::INNER, as)};
|
||||
}
|
||||
|
||||
query_where_intermediate query_on_intermediate::where(const basic_condition &cond)
|
||||
{
|
||||
return {connection_, data_};
|
||||
// return {connection_, builder_.where(cond)};
|
||||
}
|
||||
|
||||
query_group_by_intermediate query_on_intermediate::group_by(const std::string &name)
|
||||
{
|
||||
return {connection_, data_};
|
||||
|
||||
@@ -48,6 +48,11 @@ void query_join_part::accept(query_part_visitor &visitor)
|
||||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
const basic_condition &query_on_part::condition() const
|
||||
{
|
||||
return *condition_;
|
||||
}
|
||||
|
||||
void query_on_part::accept(query_part_visitor &visitor)
|
||||
{
|
||||
visitor.visit(*this);
|
||||
@@ -58,6 +63,11 @@ void query_where_part::accept(query_part_visitor &visitor)
|
||||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
const basic_condition &query_where_part::condition() const
|
||||
{
|
||||
return *condition_;
|
||||
}
|
||||
|
||||
query_table_name_part::query_table_name_part(sql::dialect::token_t token, std::string table_name)
|
||||
: query_part(token)
|
||||
, table_name_(std::move(table_name)) {}
|
||||
|
||||
Reference in New Issue
Block a user