27 #include "../../common/StringUtils.h" 28 #include "../../core/translator/Translator.h" 29 #include "../../datatype/AbstractData.h" 30 #include "../../datatype/SimpleData.h" 31 #include "../../datatype/Enums.h" 32 #include "../Exception.h" 73 #include <boost/lexical_cast.hpp> 83 if(visited.
getAlias().empty() ==
false)
96 const std::string& fname = visited.
getName();
100 if(encoder ==
nullptr)
101 throw Exception(
TE_TR(
"The informed function is not supported by this driver!"));
108 m_sql +=
"INSERT INTO ";
138 m_sql +=
" NATURAL ";
147 m_sql +=
" INNER JOIN ";
151 m_sql +=
" LEFT JOIN ";
155 m_sql +=
" RIGHT JOIN ";
159 m_sql +=
" FULL OUTER JOIN ";
163 m_sql +=
" CROSS JOIN ";
167 m_sql +=
" NATURAL JOIN ";
200 for(
size_t i = 0; i < ncols; ++i)
206 visited[i]->
accept(*
this);
352 if(visited.
getAlias().empty() ==
false)
367 for(
size_t i = 0; i < visited.
getNumArgs(); ++i)
373 visited[i]->
accept(*
this);
381 for (std::size_t i = 0; i < visited.
getNumArgs(); ++i)
423 visited[0]->
accept(*
this);
424 m_sql +=
" AS " + s_type +
" )";
428 visited[0]->
accept(*
this);
440 m_sql +=
"DISTINCT ON(";
442 std::size_t ncols = visited.size();
444 for(std::size_t i = 0; i < ncols; ++i)
449 visited[i].accept(*
this);
458 std::size_t size = visited.size();
460 for(
size_t i = 0; i < size; ++i)
465 visited[i].getExpression()->accept(*
this);
467 if (visited[i].getAlias())
470 m_sql += *(visited[i].getAlias());
477 std::size_t size = visited.size();
481 for(std::size_t i = 0; i < size; ++i)
486 visited[i].accept(*
this);
492 m_sql +=
"GROUP BY ";
494 std::size_t ncols = visited.size();
496 for(std::size_t i = 0; i < ncols; ++i)
501 visited[i].getExpression()->accept(*
this);
507 std::size_t size = visited.size();
509 m_sql +=
"ORDER BY ";
511 for(std::size_t i = 0; i < size; ++i)
516 visited[i].getExpression()->accept(*
this);
const Distinct * getDistinct() const
It returns the Distinct modifier.
const std::string & getName() const
It returns the property name.
A class that models a Literal for a integer value.
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause.
const OrderBy * getOrderBy() const
It returns the list of expressions used to sort the output result.
An abstract class that models a source of data in a query.
A class that models a Function expression.
Select * getSelect() const
It returns the associated subselect.
virtual void visitDistinct(const Distinct &visited)
A class that models the name of a dataset used in a From clause.
A class that models the name of any property of an object.
const GroupBy * getGroupBy() const
It returns the list of expressions used to condense the result set.
boost::ptr_vector< Expression > Distinct
A class that models a Distinct clause on a query.
A base class for encoders of SQL function expressions.
A class that models the name of any property of an object.
Base exception class for plugin module.
A class that represents the IN operator.
const SQLFunctionEncoder * find(const std::string &funcName) const
It searches for an encoder for the given function.
A class that models a Literal Bool value.
A class that models the name of a dataset used in a From clause.
A class that models a Distinct clause on a query.
This class models a bool Literal value.
It represents the SQL query dialect accepted by a given data source.
Expression * getCondition() const
It returns a pointer to a join condition.
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
T getValue() const
It returns the associated value.
JoinType getType() const
It returns the join type.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
A class that models a literal for ByteArray values.
#define TE_TR(message)
It marks a string in order to get translated.
The Insert object can add the return of a select object.
const From * getFrom() const
It returns the list of source information to be used by the query.
This is an abstract class that models a query expression.
A Join clause combines two FromItems.
A class that models a literal for Date and Time values.
virtual std::string toString() const =0
It returns the data value in a string notation.
JoinConditionOn is a boolean expression and it specifies which items in a join are considered to matc...
PropertyName * getPropertyName() const
It returns the property name.
bool isNatural() const
It tells if the join is Natural.
A Having is a filter expression that can be applied to a query with a group by clause.
A class that models a literal for Date and Time values.
const std::string & getAlias() const
It returns the alias associated to the source item.
This class models a literal value.
virtual void visit(const Expression &visited)
A condition to be used in a Join clause.
A class that models a Literal for a integer value.
A class that models a literal for ByteArray values.
A condition to be used in a Join clause.
Fields * getFields() const
It returns the associated fields.
std::string & m_sql
The buffer string where the query will be outputed.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
A visitor for building an SQL statement from a given Query hierarchy.
A class that models a Literal for a integer value.
A Insert can be used to add information in a table.
DataSetName * getDataSetName() const
It returns the associated DataSetName.
This is an abstract class that models a query expression.
Expression * getExp() const
A class that models a Function expression.
const Fields * getFields() const
It returns the list of output expressions used to form the result set.
A class that can be used in a GROUP BY clause.
A Join clause combines two FromItems.
Expression * getExp() const
A class that models a literal for double values.
A Select models a query to be used when retrieving data from a data source.
std::size_t getNumFields() const
It returns the number of fields in this join condition.
const std::string & getName() const
It returns the function name.
Cast a expression function.
A Select models a query to be used when retrieving data from a DataSource.
JoinConditionUsing class can be used to model a USING clause in a Join.
A class that can be used to model a GROUP BY clause.
A class that can be used to model a filter expression that can be applied to a query.
A class that models a Literal String value.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Select * getSelect() const
It returns the associated select expression.
FromItem * getSecond() const
It returns the second item involved in the join.
Where * getWhere() const
It returns the filter condition.
A class that models a literal for double values.
A Select can be used as a source of information in another query.
JoinCondition * getCondition() const
It returns the join condition.
JoinConditionUsing class can be used to model a USING clause in a Join.
const Having * getHaving() const
It returns the list of expressions used to eliminate group row that doesn't satisfy the condition...
A class that models a literal for Envelope values.
Cast a expression function.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
const std::string & getName() const
It returns the dataset name.
A Select can be used as a source of information in another query.
A class that represents the IN operator.
JoinConditionOn is a boolean expression and it specifies which items in a join are considered to matc...
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
A template for atomic data types (integers, floats, strings and others).
A Select can be used as a source of information in another query.
A class that models a literal for Geometry values.
Select * getSelect() const
It returns the associated select.
virtual void toSQL(const Function &f, std::string &buff, SQLVisitor &v) const =0
It encodes the function to a SQL notation.
te::dt::AbstractData * getValue() const
It returns the value associated to the literal.
A base class for encoders of SQL function expressions.
A Query is independent from the data source language/dialect.
std::size_t getNumArgs() const
It returns the number of arguments informed to the function.
A Select can be used as a source of information in another query.
FromItem * getFirst() const
It returns the first from item involved in the join.
A class that models a literal for Geometry values.
This class models a literal value.
This class models a string Literal value.
const SQLDialect & m_dialect
The function catalog to use when translating the query.