QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
17 #ifndef QGSSQLSTATEMENT_H
18 #define QGSSQLSTATEMENT_H
20 #include <QCoreApplication>
23 #include <QStringList>
28 #include "qgis_core.h"
57 bool hasParserError()
const;
59 QString parserErrorString()
const;
66 bool doBasicValidationChecks( QString &errorMsgOut
SIP_OUT )
const;
81 QString statement()
const;
95 static QString quotedIdentifier( QString name );
102 static QString quotedIdentifierIfNeeded(
const QString &name );
108 static QString stripQuotedIdentifier( QString text );
114 static QString stripMsQuotedIdentifier( QString text );
120 static QString quotedString( QString text );
186 static const char *BINARY_OPERATOR_TEXT[]
SIP_SKIP;
225 switch ( sipCpp->nodeType() )
240 default: sipType = 0;
break;
260 virtual QString
dump()
const = 0;
305 QList<QgsSQLStatement::Node *>
list() {
return mList; }
310 int count()
const {
return mList.count(); }
319 virtual QString dump() const;
343 QString dump()
const override;
364 , mOpRight( opRight )
378 QString dump()
const override;
384 int precedence() const;
387 bool leftAssociative() const;
417 QString dump()
const override;
437 : mNode( node ), mMinVal( minVal ), mMaxVal( maxVal ), mNotBetween( notBetween ) {}
453 QString dump()
const override;
477 QString
name()
const {
return mName; }
483 QString dump()
const override;
505 inline QVariant
value()
const {
return mValue; }
508 QString dump()
const override;
525 NodeColumnRef(
const QString &name,
bool star ) : mName( name ), mDistinct( false ), mStar( star ) {}
527 NodeColumnRef(
const QString &tableName,
const QString &name,
bool star ) : mTableName( tableName ), mName( name ), mDistinct( false ), mStar( star ) {}
530 void setDistinct(
bool distinct =
true ) { mDistinct = distinct; }
536 QString
name()
const {
return mName; }
539 bool star()
const {
return mStar; }
545 QString dump()
const override;
571 void setAlias(
const QString &alias ) { mAlias = alias; }
577 QString
alias()
const {
return mAlias; }
580 QString dump()
const override;
607 QString
type()
const {
return mType; }
610 QString dump()
const override;
630 NodeTableDef(
const QString &name,
const QString &alias ) : mName( name ), mAlias( alias ) {}
633 QString
name()
const {
return mName; }
636 QString
alias()
const {
return mAlias; }
639 QString dump()
const override;
662 ~NodeJoin()
override {
delete mTableDef;
delete mOnExpr; }
677 QString dump()
const override;
687 QList<QString> mUsingColumns;
709 QString dump()
const override;
729 NodeSelect(
const QList<QgsSQLStatement::NodeTableDef *> &tableList
SIP_TRANSFER,
const QList<QgsSQLStatement::NodeSelectedColumn *> &columns
SIP_TRANSFER,
bool distinct ) : mTableList( tableList ), mColumns( columns ), mDistinct( distinct ) {}
733 void setJoins(
const QList<QgsSQLStatement::NodeJoin *> &joins
SIP_TRANSFER ) { qDeleteAll( mJoins ); mJoins = joins; }
739 void setOrderBy(
const QList<QgsSQLStatement::NodeColumnSorted *> &orderBy
SIP_TRANSFER ) { qDeleteAll( mOrderBy ); mOrderBy = orderBy; }
742 QList<QgsSQLStatement::NodeTableDef *>
tables()
const {
return mTableList; }
744 QList<QgsSQLStatement::NodeSelectedColumn *>
columns()
const {
return mColumns; }
748 QList<QgsSQLStatement::NodeJoin *>
joins()
const {
return mJoins; }
752 QList<QgsSQLStatement::NodeColumnSorted *>
orderBy()
const {
return mOrderBy; }
755 QString dump()
const override;
838 bool mAllowFragments =
false;
872 #endif // QGSSQLSTATEMENT_H
QString tableName() const
The name of the table. May be empty.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement(const QString &statement)
Creates a new statement based on the provided string.
RecursiveVisitor()=default
Constructor.
~NodeBinaryOperator() override
NodeBetweenOperator(QgsSQLStatement::Node *node, QgsSQLStatement::Node *minVal, QgsSQLStatement::Node *maxVal, bool notBetween=false)
Constructor.
QString type() const
Type.
QgsSQLStatement::Node * operand() const
Operand.
void visit(const QgsSQLStatement::NodeFunction &n) override
Visit NodeFunction.
QString name() const
Table name.
NodeFunction(const QString &name, QgsSQLStatement::NodeList *args)
Constructor.
void visit(const QgsSQLStatement::NodeCast &n) override
Visit NodeCast.
void visit(const QgsSQLStatement::NodeBinaryOperator &n) override
Visit NodeBinaryOperator.
QgsSQLStatement::Node * opLeft() const
Left operand.
NodeJoin(QgsSQLStatement::NodeTableDef *tabledef, QgsSQLStatement::Node *onExpr, QgsSQLStatement::JoinType type)
Constructor with table definition, ON expression.
virtual void visit(const QgsSQLStatement::NodeTableDef &n)=0
Visit NodeTableDef.
void setOrderBy(const QList< QgsSQLStatement::NodeColumnSorted * > &orderBy)
Sets order by columns.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeList()=default
Constructor.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
void setWhere(QgsSQLStatement::Node *where)
Sets where clause.
virtual void visit(const QgsSQLStatement::NodeUnaryOperator &n)=0
Visit NodeUnaryOperator.
void append(QgsSQLStatement::Node *node)
Takes ownership of the provided node.
Function with a name and arguments node.
void acceptVisitor(QgsSQLStatement::Visitor &v) const
Entry function for the visitor pattern.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::Node * where() const
Returns the where clause.
void setDistinct(bool distinct=true)
Sets whether this is prefixed by DISTINCT.
virtual void visit(const QgsSQLStatement::NodeSelect &n)=0
Visit NodeSelect.
Unary logicial/arithmetical operator ( NOT, - )
void setJoins(const QList< QgsSQLStatement::NodeJoin * > &joins)
Sets joins.
void appendJoin(QgsSQLStatement::NodeJoin *join)
Append a join.
bool ascending() const
Whether the column is sorted in ascending order.
NodeLiteral(const QVariant &value)
Constructor.
NodeCast(QgsSQLStatement::Node *node, const QString &type)
Constructor.
virtual QgsSQLStatement::Node * clone() const =0
Generate a clone of this node.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QList< QgsSQLStatement::NodeSelectedColumn * > columns() const
Returns the list of columns.
QgsSQLStatement::JoinType type() const
Join type.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
~NodeColumnSorted() override
QgsSQLStatement::NodeTableDef * tableDef() const
Table definition.
QgsSQLStatement::NodeColumnRef * column() const
The name of the column.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::Node * column() const
Column that is referred to.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Support for visitor pattern - algorithms dealing with the statement may be implemented without modify...
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeSelect(const QList< QgsSQLStatement::NodeTableDef * > &tableList, const QList< QgsSQLStatement::NodeSelectedColumn * > &columns, bool distinct)
Constructor.
void visit(const QgsSQLStatement::NodeSelectedColumn &n) override
Visit NodeSelectedColumn.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeColumnRef(const QString &name, bool star)
Constructor with column name only.
void visit(const QgsSQLStatement::NodeBetweenOperator &n) override
Visit NodeBetweenOperator.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeColumnSorted(QgsSQLStatement::NodeColumnRef *column, bool asc)
Constructor.
virtual void visit(const QgsSQLStatement::NodeCast &n)=0
Visit NodeCast.
QgsSQLStatement::Node * node() const
Variable at the left of IN.
QgsSQLStatement::UnaryOperator op() const
Operator.
QList< QString > usingColumns() const
Columns referenced by USING.
bool distinct() const
Returns if the SELECT is DISTINCT.
virtual void visit(const QgsSQLStatement::NodeBetweenOperator &n)=0
Visit NodeBetweenOperator.
QString alias() const
Table alias.
QVariant value() const
The value of the literal.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QString mParserErrorString
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::BinaryOperator op() const
Operator.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
Class for parsing SQL statements.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
~NodeBetweenOperator() override
bool isNotIn() const
Whether this is a NOT IN operator.
QList< QgsSQLStatement::NodeTableDef * > tables() const
Returns the list of tables.
void setAlias(const QString &alias)
Sets alias name.
virtual QString dump() const =0
Abstract virtual dump method.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
virtual void visit(const QgsSQLStatement::NodeColumnSorted &n)=0
Visit NodeColumnSorted.
QgsSQLStatement::Node * opRight() const
Right operand.
virtual void visit(const QgsSQLStatement::NodeBinaryOperator &n)=0
Visit NodeBinaryOperator.
QgsSQLStatement::NodeList * args() const
Returns arguments.
NodeUnaryOperator(QgsSQLStatement::UnaryOperator op, QgsSQLStatement::Node *operand)
Constructor.
QgsSQLStatement::Node * node() const
Variable at the left of BETWEEN.
NodeColumnRef(const QString &tableName, const QString &name, bool star)
Constructor with table and column name.
JoinType
list of join types
Binary logical/arithmetical operator (AND, OR, =, +, ...)
NodeSelectedColumn(QgsSQLStatement::Node *node)
Constructor.
~NodeSelectedColumn() override
QList< QgsSQLStatement::NodeColumnSorted * > orderBy() const
Returns the list of order by columns.
NodeJoin(QgsSQLStatement::NodeTableDef *tabledef, const QList< QString > &usingColumns, QgsSQLStatement::JoinType type)
Constructor with table definition and USING columns.
NodeBinaryOperator(QgsSQLStatement::BinaryOperator op, QgsSQLStatement::Node *opLeft, QgsSQLStatement::Node *opRight)
Constructor.
bool star() const
Whether this is the * column.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::Node * maxVal() const
Maximum bound.
void visit(const QgsSQLStatement::NodeColumnSorted &n) override
Visit NodeColumnSorted.
virtual void visit(const QgsSQLStatement::NodeLiteral &n)=0
Visit NodeLiteral.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QString name() const
Returns function name.
virtual void accept(QgsSQLStatement::Visitor &v) const =0
Support the visitor pattern.
QList< QgsSQLStatement::NodeJoin * > joins() const
Returns the list of joins.
UnaryOperator
list of unary operators
bool isNotBetween() const
Whether this is a NOT BETWEEN operator.
virtual void visit(const QgsSQLStatement::NodeColumnRef &n)=0
Visit NodeColumnRef.
void visit(const QgsSQLStatement::NodeUnaryOperator &n) override
Visit NodeUnaryOperator.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::Node * node() const
Node that is referred to.
virtual void visit(const QgsSQLStatement::NodeFunction &n)=0
Visit NodeFunction.
void visit(const QgsSQLStatement::NodeTableDef &) override
Visit NodeTableDef.
virtual void visit(const QgsSQLStatement::NodeJoin &n)=0
Visit NodeJoin.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
void visit(const QgsSQLStatement::NodeInOperator &n) override
Visit NodeInOperator.
Class for parsing fragments of SQL statements, such as an expression or where clause.
void visit(const QgsSQLStatement::NodeLiteral &) override
Visit NodeLiteral.
NodeTableDef(const QString &name)
Constructor with table name.
NodeInOperator(QgsSQLStatement::Node *node, QgsSQLStatement::NodeList *list, bool notin=false)
Constructor.
~NodeInOperator() override
virtual QgsSQLStatement::NodeType nodeType() const =0
Abstract virtual that returns the type of this node.
NodeTableDef(const QString &name, const QString &alias)
Constructor with table name and alias.
BinaryOperator
list of binary operators
QList< QgsSQLStatement::Node * > list()
Returns list.
A visitor that recursively explores all children.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
void accept(QgsSQLStatement::Visitor &v) const
Accept visitor.
virtual void visit(const QgsSQLStatement::NodeInOperator &n)=0
Visit NodeInOperator.
QgsSQLStatement::NodeList * list() const
Values list.
QString name() const
The name of the column.
QgsSQLStatement::Node * minVal() const
Minimum bound.
'X BETWEEN y and z' operator
int count() const
Returns the number of nodes in the list.
QgsSQLStatement::Node * onExpr() const
On expression. Will be nullptr if usingColumns() is not empty.
virtual ~Visitor()=default
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
~NodeUnaryOperator() override
void visit(const QgsSQLStatement::NodeColumnRef &) override
Visit NodeColumnRef.
virtual void visit(const QgsSQLStatement::NodeSelectedColumn &n)=0
Visit NodeSelectedColumn.
bool distinct() const
Whether this is prefixed by DISTINCT.
Literal value (integer, integer64, double, string)
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QString alias() const
Alias name.