QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgssqlstatement.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssqlstatement.h
3  ---------------------
4  begin : April 2016
5  copyright : (C) 2011 by Martin Dobias
6  copyright : (C) 2016 by Even Rouault
7  email : even.rouault at spatialys.com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSSQLSTATEMENT_H
18 #define QGSSQLSTATEMENT_H
19 
20 #include <QCoreApplication>
21 #include "qgis_sip.h"
22 #include <QMetaType>
23 #include <QStringList>
24 #include <QVariant>
25 #include <QList>
26 #include <QSet>
27 
28 #include "qgis_core.h"
29 
36 class CORE_EXPORT QgsSQLStatement
37 {
38  Q_DECLARE_TR_FUNCTIONS( QgsSQLStatement )
39  public:
40 
44  QgsSQLStatement( const QString &statement );
45 
49  QgsSQLStatement( const QgsSQLStatement &other );
50 
54  QgsSQLStatement &operator=( const QgsSQLStatement &other );
55  ~QgsSQLStatement();
56 
58  bool hasParserError() const;
60  QString parserErrorString() const;
61 
67  bool doBasicValidationChecks( QString &errorMsgOut SIP_OUT ) const;
68 
69  class Node;
70 
75  const QgsSQLStatement::Node *rootNode() const;
76 
82  QString statement() const;
83 
90  QString dump() const;
91 
96  static QString quotedIdentifier( QString name );
97 
103  static QString quotedIdentifierIfNeeded( const QString &name );
104 
109  static QString stripQuotedIdentifier( QString text );
110 
115  static QString quotedString( QString text );
116 
122  {
125  };
126 
132  {
133  // logical
136 
137  // comparison
138  boEQ, // =
139  boNE, // <>
140  boLE, // <=
141  boGE, // >=
142  boLT, // <
143  boGT, // >
150 
151  // math
159 
160  // strings
162  };
163 
168  enum JoinType
169  {
177  jtFull
178  };
179 
181  static const char *BINARY_OPERATOR_TEXT[] SIP_SKIP;
182 
184  static const char *UNARY_OPERATOR_TEXT[] SIP_SKIP;
185 
187  static const char *JOIN_TYPE_TEXT[] SIP_SKIP;
188 
190 
191  class Visitor; // visitor interface is defined below
192 
194  enum NodeType
195  {
208  ntCast
209  };
210 
215  class CORE_EXPORT Node
216  {
217 
218 #ifdef SIP_RUN
220  switch ( sipCpp->nodeType() )
221  {
222  case QgsSQLStatement::ntUnaryOperator: sipType = sipType_QgsSQLStatement_NodeUnaryOperator; break;
223  case QgsSQLStatement::ntBinaryOperator: sipType = sipType_QgsSQLStatement_NodeBinaryOperator; break;
224  case QgsSQLStatement::ntInOperator: sipType = sipType_QgsSQLStatement_NodeInOperator; break;
225  case QgsSQLStatement::ntBetweenOperator: sipType = sipType_QgsSQLStatement_NodeBetweenOperator; break;
226  case QgsSQLStatement::ntFunction: sipType = sipType_QgsSQLStatement_NodeFunction; break;
227  case QgsSQLStatement::ntLiteral: sipType = sipType_QgsSQLStatement_NodeLiteral; break;
228  case QgsSQLStatement::ntColumnRef: sipType = sipType_QgsSQLStatement_NodeColumnRef; break;
229  case QgsSQLStatement::ntSelectedColumn: sipType = sipType_QgsSQLStatement_NodeSelectedColumn; break;
230  case QgsSQLStatement::ntSelect: sipType = sipType_QgsSQLStatement_NodeSelect; break;
231  case QgsSQLStatement::ntTableDef: sipType = sipType_QgsSQLStatement_NodeTableDef; break;
232  case QgsSQLStatement::ntJoin: sipType = sipType_QgsSQLStatement_NodeJoin; break;
233  case QgsSQLStatement::ntColumnSorted: sipType = sipType_QgsSQLStatement_NodeColumnSorted; break;
234  case QgsSQLStatement::ntCast: sipType = sipType_QgsSQLStatement_NodeCast; break;
235  default: sipType = 0; break;
236  }
237  SIP_END
238 #endif
239 
240  public:
241  virtual ~Node() = default;
242 
248  virtual QgsSQLStatement::NodeType nodeType() const = 0;
249 
255  virtual QString dump() const = 0;
256 
265  virtual QgsSQLStatement::Node *clone() const = 0 SIP_FACTORY;
266 
282  virtual void accept( QgsSQLStatement::Visitor &v ) const = 0;
283  };
284 
289  class CORE_EXPORT NodeList
290  {
291  public:
293  NodeList() = default;
294  virtual ~NodeList() { qDeleteAll( mList ); }
295 
297  void append( QgsSQLStatement::Node *node SIP_TRANSFER ) { mList.append( node ); }
298 
300  QList<QgsSQLStatement::Node *> list() { return mList; }
301 
305  int count() const { return mList.count(); }
306 
308  void accept( QgsSQLStatement::Visitor &v ) const;
309 
311  QgsSQLStatement::NodeList *clone() const SIP_FACTORY;
312 
314  virtual QString dump() const;
315 
316  protected:
317  QList<Node *> mList;
318  };
319 
324  class CORE_EXPORT NodeUnaryOperator : public QgsSQLStatement::Node
325  {
326  public:
328  NodeUnaryOperator( QgsSQLStatement::UnaryOperator op, QgsSQLStatement::Node *operand SIP_TRANSFER ) : mOp( op ), mOperand( operand ) {}
329  ~NodeUnaryOperator() override { delete mOperand; }
330 
332  QgsSQLStatement::UnaryOperator op() const { return mOp; }
333 
335  QgsSQLStatement::Node *operand() const { return mOperand; }
336 
338  QString dump() const override;
339 
340  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
341  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
342 
343  protected:
345  Node *mOperand = nullptr;
346  };
347 
352  class CORE_EXPORT NodeBinaryOperator : public QgsSQLStatement::Node
353  {
354  public:
357  : mOp( op )
358  , mOpLeft( opLeft )
359  , mOpRight( opRight )
360  {}
361  ~NodeBinaryOperator() override { delete mOpLeft; delete mOpRight; }
362 
364  QgsSQLStatement::BinaryOperator op() const { return mOp; }
365 
367  QgsSQLStatement::Node *opLeft() const { return mOpLeft; }
368 
370  QgsSQLStatement::Node *opRight() const { return mOpRight; }
371 
373  QString dump() const override;
374 
375  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
376  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
377 
379  int precedence() const;
380 
382  bool leftAssociative() const;
383 
384  protected:
385 
387  Node *mOpLeft = nullptr;
388  Node *mOpRight = nullptr;
389  };
390 
395  class CORE_EXPORT NodeInOperator : public QgsSQLStatement::Node
396  {
397  public:
399  NodeInOperator( QgsSQLStatement::Node *node SIP_TRANSFER, QgsSQLStatement::NodeList *list SIP_TRANSFER, bool notin = false ) : mNode( node ), mList( list ), mNotIn( notin ) {}
400  ~NodeInOperator() override { delete mNode; delete mList; }
401 
403  QgsSQLStatement::Node *node() const { return mNode; }
404 
406  bool isNotIn() const { return mNotIn; }
407 
409  QgsSQLStatement::NodeList *list() const { return mList; }
410 
411  QgsSQLStatement::NodeType nodeType() const override { return ntInOperator; }
412  QString dump() const override;
413 
414  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
415  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
416 
417  protected:
418  Node *mNode = nullptr;
419  NodeList *mList = nullptr;
420  bool mNotIn;
421  };
422 
427  class CORE_EXPORT NodeBetweenOperator : public QgsSQLStatement::Node
428  {
429  public:
431  NodeBetweenOperator( QgsSQLStatement::Node *node SIP_TRANSFER, QgsSQLStatement::Node *minVal SIP_TRANSFER, QgsSQLStatement::Node *maxVal SIP_TRANSFER, bool notBetween = false )
432  : mNode( node ), mMinVal( minVal ), mMaxVal( maxVal ), mNotBetween( notBetween ) {}
433  ~NodeBetweenOperator() override { delete mNode; delete mMinVal; delete mMaxVal; }
434 
436  QgsSQLStatement::Node *node() const { return mNode; }
437 
439  bool isNotBetween() const { return mNotBetween; }
440 
442  QgsSQLStatement::Node *minVal() const { return mMinVal; }
443 
445  QgsSQLStatement::Node *maxVal() const { return mMaxVal; }
446 
448  QString dump() const override;
449 
450  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
451  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
452 
453  protected:
454  Node *mNode = nullptr;
455  Node *mMinVal = nullptr;
456  Node *mMaxVal = nullptr;
458  };
459 
464  class CORE_EXPORT NodeFunction : public QgsSQLStatement::Node
465  {
466  public:
468  NodeFunction( const QString &name, QgsSQLStatement::NodeList *args SIP_TRANSFER ) : mName( name ), mArgs( args ) {}
469  ~NodeFunction() override { delete mArgs; }
470 
472  QString name() const { return mName; }
473 
475  QgsSQLStatement::NodeList *args() const { return mArgs; }
476 
477  QgsSQLStatement::NodeType nodeType() const override { return ntFunction; }
478  QString dump() const override;
479 
480  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
481  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
482 
483  protected:
484  QString mName;
485  NodeList *mArgs = nullptr;
486 
487  };
488 
493  class CORE_EXPORT NodeLiteral : public QgsSQLStatement::Node
494  {
495  public:
497  NodeLiteral( const QVariant &value ) : mValue( value ) {}
498 
500  inline QVariant value() const { return mValue; }
501 
502  QgsSQLStatement::NodeType nodeType() const override { return ntLiteral; }
503  QString dump() const override;
504 
505  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
506  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
507 
508  protected:
509  QVariant mValue;
510  };
511 
516  class CORE_EXPORT NodeColumnRef : public QgsSQLStatement::Node
517  {
518  public:
520  NodeColumnRef( const QString &name, bool star ) : mName( name ), mDistinct( false ), mStar( star ) {}
522  NodeColumnRef( const QString &tableName, const QString &name, bool star ) : mTableName( tableName ), mName( name ), mDistinct( false ), mStar( star ) {}
523 
525  void setDistinct( bool distinct = true ) { mDistinct = distinct; }
526 
528  QString tableName() const { return mTableName; }
529 
531  QString name() const { return mName; }
532 
534  bool star() const { return mStar; }
535 
537  bool distinct() const { return mDistinct; }
538 
539  QgsSQLStatement::NodeType nodeType() const override { return ntColumnRef; }
540  QString dump() const override;
541 
542  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
543  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
545  QgsSQLStatement::NodeColumnRef *cloneThis() const SIP_FACTORY;
546 
547  protected:
548  QString mTableName;
549  QString mName;
550  bool mDistinct;
551  bool mStar;
552  };
553 
558  class CORE_EXPORT NodeSelectedColumn : public QgsSQLStatement::Node
559  {
560  public:
562  NodeSelectedColumn( QgsSQLStatement::Node *node SIP_TRANSFER ) : mColumnNode( node ) {}
563  ~NodeSelectedColumn() override { delete mColumnNode; }
564 
566  void setAlias( const QString &alias ) { mAlias = alias; }
567 
569  QgsSQLStatement::Node *column() const { return mColumnNode; }
570 
572  QString alias() const { return mAlias; }
573 
575  QString dump() const override;
576 
577  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
578  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
581 
582  protected:
583  Node *mColumnNode = nullptr;
584  QString mAlias;
585  };
586 
591  class CORE_EXPORT NodeCast : public QgsSQLStatement::Node
592  {
593  public:
595  NodeCast( QgsSQLStatement::Node *node SIP_TRANSFER, const QString &type ) : mNode( node ), mType( type ) {}
596  ~NodeCast() override { delete mNode; }
597 
599  QgsSQLStatement::Node *node() const { return mNode; }
600 
602  QString type() const { return mType; }
603 
604  QgsSQLStatement::NodeType nodeType() const override { return ntCast; }
605  QString dump() const override;
606 
607  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
608  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
609 
610  protected:
611  Node *mNode = nullptr;
612  QString mType;
613  };
614 
619  class CORE_EXPORT NodeTableDef : public QgsSQLStatement::Node
620  {
621  public:
623  NodeTableDef( const QString &name ) : mName( name ) {}
625  NodeTableDef( const QString &name, const QString &alias ) : mName( name ), mAlias( alias ) {}
626 
628  QString name() const { return mName; }
629 
631  QString alias() const { return mAlias; }
632 
633  QgsSQLStatement::NodeType nodeType() const override { return ntTableDef; }
634  QString dump() const override;
635 
636  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
637  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
639  QgsSQLStatement::NodeTableDef *cloneThis() const SIP_FACTORY;
640 
641  protected:
642  QString mName;
643  QString mAlias;
644  };
645 
650  class CORE_EXPORT NodeJoin : public QgsSQLStatement::Node
651  {
652  public:
654  NodeJoin( QgsSQLStatement::NodeTableDef *tabledef SIP_TRANSFER, QgsSQLStatement::Node *onExpr SIP_TRANSFER, QgsSQLStatement::JoinType type ) : mTableDef( tabledef ), mOnExpr( onExpr ), mType( type ) {}
656  NodeJoin( QgsSQLStatement::NodeTableDef *tabledef SIP_TRANSFER, const QList<QString> &usingColumns, QgsSQLStatement::JoinType type ) : mTableDef( tabledef ), mUsingColumns( usingColumns ), mType( type ) {}
657  ~NodeJoin() override { delete mTableDef; delete mOnExpr; }
658 
660  QgsSQLStatement::NodeTableDef *tableDef() const { return mTableDef; }
661 
663  QgsSQLStatement::Node *onExpr() const { return mOnExpr; }
664 
666  QList<QString> usingColumns() const { return mUsingColumns; }
667 
669  QgsSQLStatement::JoinType type() const { return mType; }
670 
671  QgsSQLStatement::NodeType nodeType() const override { return ntJoin; }
672  QString dump() const override;
673 
674  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
675  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
677  QgsSQLStatement::NodeJoin *cloneThis() const SIP_FACTORY;
678 
679  protected:
680  NodeTableDef *mTableDef = nullptr;
681  Node *mOnExpr = nullptr;
682  QList<QString> mUsingColumns;
684  };
685 
690  class CORE_EXPORT NodeColumnSorted : public QgsSQLStatement::Node
691  {
692  public:
694  NodeColumnSorted( QgsSQLStatement::NodeColumnRef *column SIP_TRANSFER, bool asc ) : mColumn( column ), mAsc( asc ) {}
695  ~NodeColumnSorted() override { delete mColumn; }
696 
698  QgsSQLStatement::NodeColumnRef *column() const { return mColumn; }
699 
701  bool ascending() const { return mAsc; }
702 
703  QgsSQLStatement::NodeType nodeType() const override { return ntColumnSorted; }
704  QString dump() const override;
705 
706  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
707  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
710 
711  protected:
712  NodeColumnRef *mColumn = nullptr;
713  bool mAsc;
714  };
715 
720  class CORE_EXPORT NodeSelect : public QgsSQLStatement::Node
721  {
722  public:
724  NodeSelect( const QList<QgsSQLStatement::NodeTableDef *> &tableList SIP_TRANSFER, const QList<QgsSQLStatement::NodeSelectedColumn *> &columns SIP_TRANSFER, bool distinct ) : mTableList( tableList ), mColumns( columns ), mDistinct( distinct ) {}
725  ~NodeSelect() override;
726 
728  void setJoins( const QList<QgsSQLStatement::NodeJoin *> &joins SIP_TRANSFER ) { qDeleteAll( mJoins ); mJoins = joins; }
730  void appendJoin( QgsSQLStatement::NodeJoin *join SIP_TRANSFER ) { mJoins.append( join ); }
732  void setWhere( QgsSQLStatement::Node *where SIP_TRANSFER ) { delete mWhere; mWhere = where; }
734  void setOrderBy( const QList<QgsSQLStatement::NodeColumnSorted *> &orderBy SIP_TRANSFER ) { qDeleteAll( mOrderBy ); mOrderBy = orderBy; }
735 
737  QList<QgsSQLStatement::NodeTableDef *> tables() const { return mTableList; }
739  QList<QgsSQLStatement::NodeSelectedColumn *> columns() const { return mColumns; }
741  bool distinct() const { return mDistinct; }
743  QList<QgsSQLStatement::NodeJoin *> joins() const { return mJoins; }
745  QgsSQLStatement::Node *where() const { return mWhere; }
747  QList<QgsSQLStatement::NodeColumnSorted *> orderBy() const { return mOrderBy; }
748 
749  QgsSQLStatement::NodeType nodeType() const override { return ntSelect; }
750  QString dump() const override;
751 
752  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
753  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
754 
755  protected:
756  QList<NodeTableDef *> mTableList;
757  QList<NodeSelectedColumn *> mColumns;
758  bool mDistinct;
759  QList<NodeJoin *> mJoins;
760  Node *mWhere = nullptr;
761  QList<NodeColumnSorted *> mOrderBy;
762  };
763 
765 
771  class CORE_EXPORT Visitor
772  {
773  public:
774  virtual ~Visitor() = default;
776  virtual void visit( const QgsSQLStatement::NodeUnaryOperator &n ) = 0;
778  virtual void visit( const QgsSQLStatement::NodeBinaryOperator &n ) = 0;
780  virtual void visit( const QgsSQLStatement::NodeInOperator &n ) = 0;
782  virtual void visit( const QgsSQLStatement::NodeBetweenOperator &n ) = 0;
784  virtual void visit( const QgsSQLStatement::NodeFunction &n ) = 0;
786  virtual void visit( const QgsSQLStatement::NodeLiteral &n ) = 0;
788  virtual void visit( const QgsSQLStatement::NodeColumnRef &n ) = 0;
790  virtual void visit( const QgsSQLStatement::NodeSelectedColumn &n ) = 0;
792  virtual void visit( const QgsSQLStatement::NodeTableDef &n ) = 0;
794  virtual void visit( const QgsSQLStatement::NodeSelect &n ) = 0;
796  virtual void visit( const QgsSQLStatement::NodeJoin &n ) = 0;
798  virtual void visit( const QgsSQLStatement::NodeColumnSorted &n ) = 0;
800  virtual void visit( const QgsSQLStatement::NodeCast &n ) = 0;
801  };
802 
807  class CORE_EXPORT RecursiveVisitor: public QgsSQLStatement::Visitor
808  {
809  public:
811  RecursiveVisitor() = default;
812 
813  void visit( const QgsSQLStatement::NodeUnaryOperator &n ) override { n.operand()->accept( *this ); }
814  void visit( const QgsSQLStatement::NodeBinaryOperator &n ) override { n.opLeft()->accept( *this ); n.opRight()->accept( *this ); }
815  void visit( const QgsSQLStatement::NodeInOperator &n ) override { n.node()->accept( *this ); n.list()->accept( *this ); }
816  void visit( const QgsSQLStatement::NodeBetweenOperator &n ) override { n.node()->accept( *this ); n.minVal()->accept( *this ); n.maxVal()->accept( *this ); }
817  void visit( const QgsSQLStatement::NodeFunction &n ) override { n.args()->accept( *this ); }
818  void visit( const QgsSQLStatement::NodeLiteral & ) override {}
819  void visit( const QgsSQLStatement::NodeColumnRef & ) override { }
820  void visit( const QgsSQLStatement::NodeSelectedColumn &n ) override { n.column()->accept( *this ); }
821  void visit( const QgsSQLStatement::NodeTableDef & ) override {}
822  void visit( const QgsSQLStatement::NodeSelect &n ) override;
823  void visit( const QgsSQLStatement::NodeJoin &n ) override;
824  void visit( const QgsSQLStatement::NodeColumnSorted &n ) override { n.column()->accept( *this ); }
825  void visit( const QgsSQLStatement::NodeCast &n ) override { n.node()->accept( *this ); }
826  };
827 
829  void acceptVisitor( QgsSQLStatement::Visitor &v ) const;
830 
831  protected:
832  QgsSQLStatement::Node *mRootNode = nullptr;
833  QString mStatement;
835 };
836 
838 
839 #endif // QGSSQLSTATEMENT_H
bool ascending() const
Whether the column is sorted in ascending order.
QgsSQLStatement::NodeList * list() const
Values list.
NodeTableDef(const QString &name)
Constructor with table name.
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.
QgsSQLStatement::Node * onExpr() const
On expression. Will be nullptr if usingColumns() is not empty.
void appendJoin(QgsSQLStatement::NodeJoin *join)
Append a join.
Function with a name and arguments node.
JoinType
list of join types
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QList< NodeJoin * > mJoins
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::NodeTableDef * tableDef() const
Table definition.
QString type() const
Type.
QgsSQLStatement::Node * operand() const
Operand.
QgsSQLStatement::Node * where() const
Returns the where clause.
QList< NodeColumnSorted * > mOrderBy
UnaryOperator
list of unary operators
NodeTableDef(const QString &name, const QString &alias)
Constructor with table name and alias.
NodeUnaryOperator(QgsSQLStatement::UnaryOperator op, QgsSQLStatement::Node *operand)
Constructor.
void visit(const QgsSQLStatement::NodeSelectedColumn &n) override
Visit NodeSelectedColumn.
NodeJoin(QgsSQLStatement::NodeTableDef *tabledef, const QList< QString > &usingColumns, QgsSQLStatement::JoinType type)
Constructor with table definition and USING columns.
NodeBetweenOperator(QgsSQLStatement::Node *node, QgsSQLStatement::Node *minVal, QgsSQLStatement::Node *maxVal, bool notBetween=false)
Constructor.
Binary logical/arithmetical operator (AND, OR, =, +, ...)
NodeSelect(const QList< QgsSQLStatement::NodeTableDef *> &tableList, const QList< QgsSQLStatement::NodeSelectedColumn *> &columns, bool distinct)
Constructor.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QList< QString > mUsingColumns
QList< QgsSQLStatement::NodeSelectedColumn * > columns() const
Returns the list of columns.
NodeType
Node type.
NodeSelectedColumn(QgsSQLStatement::Node *node)
Constructor.
QString name() const
Returns function name.
NodeBinaryOperator(QgsSQLStatement::BinaryOperator op, QgsSQLStatement::Node *opLeft, QgsSQLStatement::Node *opRight)
Constructor.
bool distinct() const
Returns if the SELECT is DISTINCT.
Abstract node class.
QgsSQLStatement::Node * node() const
Variable at the left of BETWEEN.
QList< QString > usingColumns() const
Columns referenced by USING.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
void setWhere(QgsSQLStatement::Node *where)
Sets where clause.
NodeFunction(const QString &name, QgsSQLStatement::NodeList *args)
Constructor.
QgsSQLStatement::JoinType type() const
Join type.
QgsSQLStatement::Node * minVal() const
Minimum bound.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
A visitor that recursively explores all children.
virtual void visit(const QgsSQLStatement::NodeUnaryOperator &n)=0
Visit NodeUnaryOperator.
bool isNotIn() const
Whether this is a NOT IN operator.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeCast(QgsSQLStatement::Node *node, const QString &type)
Constructor.
Class for parsing SQL statements.
QString name() const
Table name.
QString alias() const
Table alias.
virtual QString dump() const =0
Abstract virtual dump method.
void visit(const QgsSQLStatement::NodeBetweenOperator &n) override
Visit NodeBetweenOperator.
virtual QgsSQLStatement::Node * clone() const =0
Generate a clone of this node.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
NodeColumnSorted(QgsSQLStatement::NodeColumnRef *column, bool asc)
Constructor.
QgsSQLStatement::NodeList * args() const
Returns arguments.
void setOrderBy(const QList< QgsSQLStatement::NodeColumnSorted *> &orderBy)
Sets order by columns.
NodeInOperator(QgsSQLStatement::Node *node, QgsSQLStatement::NodeList *list, bool notin=false)
Constructor.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
Literal value (integer, integer64, double, string)
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QString name() const
The name of the column.
QList< QgsSQLStatement::NodeTableDef * > tables() const
Returns the list of tables.
#define SIP_END
Definition: qgis_sip.h:189
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
void setAlias(const QString &alias)
Sets alias name.
Unary logicial/arithmetical operator ( NOT, - )
QgsSQLStatement::BinaryOperator op() const
Operator.
QList< NodeTableDef * > mTableList
BinaryOperator
list of binary operators
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QList< NodeSelectedColumn * > mColumns
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
bool distinct() const
Whether this is prefixed by DISTINCT.
QString alias() const
Alias name.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::Node * maxVal() const
Maximum bound.
bool isNotBetween() const
Whether this is a NOT BETWEEN operator.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QList< QgsSQLStatement::NodeColumnSorted * > orderBy() const
Returns the list of order by columns.
Reference to a column.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
&#39;X BETWEEN y and z&#39; operator
void visit(const QgsSQLStatement::NodeColumnSorted &n) override
Visit NodeColumnSorted.
void accept(QgsSQLStatement::Visitor &v) const
Accept visitor.
QVariant value() const
The value of the literal.
QList< QgsSQLStatement::NodeJoin * > joins() const
Returns the list of joins.
void visit(const QgsSQLStatement::NodeLiteral &) override
Visit NodeLiteral.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::NodeColumnRef * column() const
The name of the column.
void setJoins(const QList< QgsSQLStatement::NodeJoin *> &joins)
Sets joins.
void acceptVisitor(QgsSQLStatement::Visitor &v) const
Entry function for the visitor pattern.
NodeJoin(QgsSQLStatement::NodeTableDef *tabledef, QgsSQLStatement::Node *onExpr, QgsSQLStatement::JoinType type)
Constructor with table definition, ON expression.
void visit(const QgsSQLStatement::NodeInOperator &n) override
Visit NodeInOperator.
bool star() const
Whether this is the * column.
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.
virtual void accept(QgsSQLStatement::Visitor &v) const =0
Support the visitor pattern.
QList< QgsSQLStatement::Node * > list()
Returns list.
NodeColumnRef(const QString &tableName, const QString &name, bool star)
Constructor with table and column name.
#define SIP_OUT
Definition: qgis_sip.h:58
QgsSQLStatement::Node * node() const
Node that is referred to.
void setDistinct(bool distinct=true)
Sets whether this is prefixed by DISTINCT.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
void visit(const QgsSQLStatement::NodeUnaryOperator &n) override
Visit NodeUnaryOperator.
void visit(const QgsSQLStatement::NodeColumnRef &) override
Visit NodeColumnRef.
Support for visitor pattern - algorithms dealing with the statement may be implemented without modify...
void visit(const QgsSQLStatement::NodeTableDef &) override
Visit NodeTableDef.
QString tableName() const
The name of the table. May be empty.
void append(QgsSQLStatement::Node *node)
Takes ownership of the provided node.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::UnaryOperator op() const
Operator.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
&#39;x IN (y, z)&#39; operator
QgsSQLStatement::Node * node() const
Variable at the left of IN.
void visit(const QgsSQLStatement::NodeFunction &n) override
Visit NodeFunction.
QgsSQLStatement::Node * opLeft() const
Left operand.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::Node * opRight() const
Right operand.
NodeColumnRef(const QString &name, bool star)
Constructor with column name only.
void visit(const QgsSQLStatement::NodeCast &n) override
Visit NodeCast.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
void visit(const QgsSQLStatement::NodeBinaryOperator &n) override
Visit NodeBinaryOperator.
NodeLiteral(const QVariant &value)
Constructor.
QgsSQLStatement::Node * column() const
Column that is referred to.
QString mParserErrorString
int count() const
Returns the number of nodes in the list.