QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
35 class CORE_EXPORT QgsSQLStatement
36 {
37  Q_DECLARE_TR_FUNCTIONS( QgsSQLStatement )
38  public:
39 
43  QgsSQLStatement( const QString &statement );
44 
48  QgsSQLStatement( const QgsSQLStatement &other );
49 
53  QgsSQLStatement &operator=( const QgsSQLStatement &other );
54  virtual ~QgsSQLStatement();
55 
57  bool hasParserError() const;
59  QString parserErrorString() const;
60 
66  bool doBasicValidationChecks( QString &errorMsgOut SIP_OUT ) const;
67 
68  class Node;
69 
74  const QgsSQLStatement::Node *rootNode() const;
75 
81  QString statement() const;
82 
89  QString dump() const;
90 
95  static QString quotedIdentifier( QString name );
96 
102  static QString quotedIdentifierIfNeeded( const QString &name );
103 
108  static QString stripQuotedIdentifier( QString text );
109 
114  static QString stripMsQuotedIdentifier( QString text );
115 
120  static QString quotedString( QString text );
121 
126  enum UnaryOperator
127  {
128  uoNot,
129  uoMinus,
130  };
131 
136  enum BinaryOperator
137  {
138  // logical
139  boOr,
140  boAnd,
141 
142  // comparison
143  boEQ, // =
144  boNE, // <>
145  boLE, // <=
146  boGE, // >=
147  boLT, // <
148  boGT, // >
149  boLike,
150  boNotLike,
151  boILike,
152  boNotILike,
153  boIs,
154  boIsNot,
155 
156  // math
157  boPlus,
158  boMinus,
159  boMul,
160  boDiv,
161  boIntDiv,
162  boMod,
163  boPow,
164 
165  // strings
166  boConcat,
167  };
168 
173  enum JoinType
174  {
175  jtDefault,
176  jtLeft,
177  jtLeftOuter,
178  jtRight,
179  jtRightOuter,
180  jtCross,
181  jtInner,
182  jtFull
183  };
184 
186  static const char *BINARY_OPERATOR_TEXT[] SIP_SKIP;
187 
189  static const char *UNARY_OPERATOR_TEXT[] SIP_SKIP;
190 
192  static const char *JOIN_TYPE_TEXT[] SIP_SKIP;
193 
195 
196  class Visitor; // visitor interface is defined below
197 
199  enum NodeType
200  {
201  ntUnaryOperator,
202  ntBinaryOperator,
203  ntInOperator,
204  ntBetweenOperator,
205  ntFunction,
206  ntLiteral,
207  ntColumnRef,
208  ntSelectedColumn,
209  ntSelect,
210  ntTableDef,
211  ntJoin,
212  ntColumnSorted,
213  ntCast
214  };
215 
220  class CORE_EXPORT Node
221  {
222 
223 #ifdef SIP_RUN
225  switch ( sipCpp->nodeType() )
226  {
227  case QgsSQLStatement::ntUnaryOperator: sipType = sipType_QgsSQLStatement_NodeUnaryOperator; break;
228  case QgsSQLStatement::ntBinaryOperator: sipType = sipType_QgsSQLStatement_NodeBinaryOperator; break;
229  case QgsSQLStatement::ntInOperator: sipType = sipType_QgsSQLStatement_NodeInOperator; break;
230  case QgsSQLStatement::ntBetweenOperator: sipType = sipType_QgsSQLStatement_NodeBetweenOperator; break;
231  case QgsSQLStatement::ntFunction: sipType = sipType_QgsSQLStatement_NodeFunction; break;
232  case QgsSQLStatement::ntLiteral: sipType = sipType_QgsSQLStatement_NodeLiteral; break;
233  case QgsSQLStatement::ntColumnRef: sipType = sipType_QgsSQLStatement_NodeColumnRef; break;
234  case QgsSQLStatement::ntSelectedColumn: sipType = sipType_QgsSQLStatement_NodeSelectedColumn; break;
235  case QgsSQLStatement::ntSelect: sipType = sipType_QgsSQLStatement_NodeSelect; break;
236  case QgsSQLStatement::ntTableDef: sipType = sipType_QgsSQLStatement_NodeTableDef; break;
237  case QgsSQLStatement::ntJoin: sipType = sipType_QgsSQLStatement_NodeJoin; break;
238  case QgsSQLStatement::ntColumnSorted: sipType = sipType_QgsSQLStatement_NodeColumnSorted; break;
239  case QgsSQLStatement::ntCast: sipType = sipType_QgsSQLStatement_NodeCast; break;
240  default: sipType = 0; break;
241  }
242  SIP_END
243 #endif
244 
245  public:
246  virtual ~Node() = default;
247 
253  virtual QgsSQLStatement::NodeType nodeType() const = 0;
254 
260  virtual QString dump() const = 0;
261 
270  virtual QgsSQLStatement::Node *clone() const = 0 SIP_FACTORY;
271 
287  virtual void accept( QgsSQLStatement::Visitor &v ) const = 0;
288  };
289 
294  class CORE_EXPORT NodeList
295  {
296  public:
298  NodeList() = default;
299  virtual ~NodeList() { qDeleteAll( mList ); }
300 
302  void append( QgsSQLStatement::Node *node SIP_TRANSFER ) { mList.append( node ); }
303 
305  QList<QgsSQLStatement::Node *> list() { return mList; }
306 
310  int count() const { return mList.count(); }
311 
313  void accept( QgsSQLStatement::Visitor &v ) const;
314 
317 
319  virtual QString dump() const;
320 
321  protected:
322  QList<Node *> mList;
323  };
324 
329  class CORE_EXPORT NodeUnaryOperator : public QgsSQLStatement::Node
330  {
331  public:
333  NodeUnaryOperator( QgsSQLStatement::UnaryOperator op, QgsSQLStatement::Node *operand SIP_TRANSFER ) : mOp( op ), mOperand( operand ) {}
334  ~NodeUnaryOperator() override { delete mOperand; }
335 
337  QgsSQLStatement::UnaryOperator op() const { return mOp; }
338 
340  QgsSQLStatement::Node *operand() const { return mOperand; }
341 
342  QgsSQLStatement::NodeType nodeType() const override { return ntUnaryOperator; }
343  QString dump() const override;
344 
345  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
346  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
347 
348  protected:
349  UnaryOperator mOp;
350  Node *mOperand = nullptr;
351  };
352 
357  class CORE_EXPORT NodeBinaryOperator : public QgsSQLStatement::Node
358  {
359  public:
362  : mOp( op )
363  , mOpLeft( opLeft )
364  , mOpRight( opRight )
365  {}
366  ~NodeBinaryOperator() override { delete mOpLeft; delete mOpRight; }
367 
369  QgsSQLStatement::BinaryOperator op() const { return mOp; }
370 
372  QgsSQLStatement::Node *opLeft() const { return mOpLeft; }
373 
375  QgsSQLStatement::Node *opRight() const { return mOpRight; }
376 
377  QgsSQLStatement::NodeType nodeType() const override { return ntBinaryOperator; }
378  QString dump() const override;
379 
380  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
381  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
382 
384  int precedence() const;
385 
387  bool leftAssociative() const;
388 
389  protected:
390 
392  Node *mOpLeft = nullptr;
393  Node *mOpRight = nullptr;
394  };
395 
400  class CORE_EXPORT NodeInOperator : public QgsSQLStatement::Node
401  {
402  public:
404  NodeInOperator( QgsSQLStatement::Node *node SIP_TRANSFER, QgsSQLStatement::NodeList *list SIP_TRANSFER, bool notin = false ) : mNode( node ), mList( list ), mNotIn( notin ) {}
405  ~NodeInOperator() override { delete mNode; delete mList; }
406 
408  QgsSQLStatement::Node *node() const { return mNode; }
409 
411  bool isNotIn() const { return mNotIn; }
412 
414  QgsSQLStatement::NodeList *list() const { return mList; }
415 
416  QgsSQLStatement::NodeType nodeType() const override { return ntInOperator; }
417  QString dump() const override;
418 
419  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
420  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
421 
422  protected:
423  Node *mNode = nullptr;
424  NodeList *mList = nullptr;
425  bool mNotIn;
426  };
427 
432  class CORE_EXPORT NodeBetweenOperator : public QgsSQLStatement::Node
433  {
434  public:
437  : mNode( node ), mMinVal( minVal ), mMaxVal( maxVal ), mNotBetween( notBetween ) {}
438  ~NodeBetweenOperator() override { delete mNode; delete mMinVal; delete mMaxVal; }
439 
441  QgsSQLStatement::Node *node() const { return mNode; }
442 
444  bool isNotBetween() const { return mNotBetween; }
445 
447  QgsSQLStatement::Node *minVal() const { return mMinVal; }
448 
450  QgsSQLStatement::Node *maxVal() const { return mMaxVal; }
451 
452  QgsSQLStatement::NodeType nodeType() const override { return ntBetweenOperator; }
453  QString dump() const override;
454 
455  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
456  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
457 
458  protected:
459  Node *mNode = nullptr;
460  Node *mMinVal = nullptr;
461  Node *mMaxVal = nullptr;
462  bool mNotBetween;
463  };
464 
469  class CORE_EXPORT NodeFunction : public QgsSQLStatement::Node
470  {
471  public:
473  NodeFunction( const QString &name, QgsSQLStatement::NodeList *args SIP_TRANSFER ) : mName( name ), mArgs( args ) {}
474  ~NodeFunction() override { delete mArgs; }
475 
477  QString name() const { return mName; }
478 
480  QgsSQLStatement::NodeList *args() const { return mArgs; }
481 
482  QgsSQLStatement::NodeType nodeType() const override { return ntFunction; }
483  QString dump() const override;
484 
485  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
486  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
487 
488  protected:
489  QString mName;
490  NodeList *mArgs = nullptr;
491 
492  };
493 
498  class CORE_EXPORT NodeLiteral : public QgsSQLStatement::Node
499  {
500  public:
502  NodeLiteral( const QVariant &value ) : mValue( value ) {}
503 
505  inline QVariant value() const { return mValue; }
506 
507  QgsSQLStatement::NodeType nodeType() const override { return ntLiteral; }
508  QString dump() const override;
509 
510  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
511  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
512 
513  protected:
514  QVariant mValue;
515  };
516 
521  class CORE_EXPORT NodeColumnRef : public QgsSQLStatement::Node
522  {
523  public:
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 ) {}
528 
530  void setDistinct( bool distinct = true ) { mDistinct = distinct; }
531 
533  QString tableName() const { return mTableName; }
534 
536  QString name() const { return mName; }
537 
539  bool star() const { return mStar; }
540 
542  bool distinct() const { return mDistinct; }
543 
544  QgsSQLStatement::NodeType nodeType() const override { return ntColumnRef; }
545  QString dump() const override;
546 
547  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
548  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
551 
552  protected:
553  QString mTableName;
554  QString mName;
555  bool mDistinct;
556  bool mStar;
557  };
558 
563  class CORE_EXPORT NodeSelectedColumn : public QgsSQLStatement::Node
564  {
565  public:
567  NodeSelectedColumn( QgsSQLStatement::Node *node SIP_TRANSFER ) : mColumnNode( node ) {}
568  ~NodeSelectedColumn() override { delete mColumnNode; }
569 
571  void setAlias( const QString &alias ) { mAlias = alias; }
572 
574  QgsSQLStatement::Node *column() const { return mColumnNode; }
575 
577  QString alias() const { return mAlias; }
578 
579  QgsSQLStatement::NodeType nodeType() const override { return ntSelectedColumn; }
580  QString dump() const override;
581 
582  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
583  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
586 
587  protected:
588  Node *mColumnNode = nullptr;
589  QString mAlias;
590  };
591 
596  class CORE_EXPORT NodeCast : public QgsSQLStatement::Node
597  {
598  public:
600  NodeCast( QgsSQLStatement::Node *node SIP_TRANSFER, const QString &type ) : mNode( node ), mType( type ) {}
601  ~NodeCast() override { delete mNode; }
602 
604  QgsSQLStatement::Node *node() const { return mNode; }
605 
607  QString type() const { return mType; }
608 
609  QgsSQLStatement::NodeType nodeType() const override { return ntCast; }
610  QString dump() const override;
611 
612  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
613  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
614 
615  protected:
616  Node *mNode = nullptr;
617  QString mType;
618  };
619 
624  class CORE_EXPORT NodeTableDef : public QgsSQLStatement::Node
625  {
626  public:
628  NodeTableDef( const QString &name ) : mName( name ) {}
630  NodeTableDef( const QString &name, const QString &alias ) : mName( name ), mAlias( alias ) {}
631 
636  NodeTableDef( const QString &schema, const QString &name, const QString &alias ) : mName( name ), mSchema( schema ), mAlias( alias ) {}
637 
639  QString name() const { return mName; }
640 
646  QString schema() const { return mSchema; }
647 
649  QString alias() const { return mAlias; }
650 
651  QgsSQLStatement::NodeType nodeType() const override { return ntTableDef; }
652  QString dump() const override;
653 
654  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
655  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
657  QgsSQLStatement::NodeTableDef *cloneThis() const SIP_FACTORY;
658 
659  protected:
660  QString mName;
661  QString mSchema;
662  QString mAlias;
663  };
664 
669  class CORE_EXPORT NodeJoin : public QgsSQLStatement::Node
670  {
671  public:
673  NodeJoin( QgsSQLStatement::NodeTableDef *tabledef SIP_TRANSFER, QgsSQLStatement::Node *onExpr SIP_TRANSFER, QgsSQLStatement::JoinType type ) : mTableDef( tabledef ), mOnExpr( onExpr ), mType( type ) {}
675  NodeJoin( QgsSQLStatement::NodeTableDef *tabledef SIP_TRANSFER, const QList<QString> &usingColumns, QgsSQLStatement::JoinType type ) : mTableDef( tabledef ), mUsingColumns( usingColumns ), mType( type ) {}
676  ~NodeJoin() override { delete mTableDef; delete mOnExpr; }
677 
679  QgsSQLStatement::NodeTableDef *tableDef() const { return mTableDef; }
680 
682  QgsSQLStatement::Node *onExpr() const { return mOnExpr; }
683 
685  QList<QString> usingColumns() const { return mUsingColumns; }
686 
688  QgsSQLStatement::JoinType type() const { return mType; }
689 
690  QgsSQLStatement::NodeType nodeType() const override { return ntJoin; }
691  QString dump() const override;
692 
693  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
694  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
696  QgsSQLStatement::NodeJoin *cloneThis() const SIP_FACTORY;
697 
698  protected:
699  NodeTableDef *mTableDef = nullptr;
700  Node *mOnExpr = nullptr;
701  QList<QString> mUsingColumns;
702  JoinType mType;
703  };
704 
709  class CORE_EXPORT NodeColumnSorted : public QgsSQLStatement::Node
710  {
711  public:
713  NodeColumnSorted( QgsSQLStatement::NodeColumnRef *column SIP_TRANSFER, bool asc ) : mColumn( column ), mAsc( asc ) {}
714  ~NodeColumnSorted() override { delete mColumn; }
715 
717  QgsSQLStatement::NodeColumnRef *column() const { return mColumn; }
718 
720  bool ascending() const { return mAsc; }
721 
722  QgsSQLStatement::NodeType nodeType() const override { return ntColumnSorted; }
723  QString dump() const override;
724 
725  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
726  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
729 
730  protected:
731  NodeColumnRef *mColumn = nullptr;
732  bool mAsc;
733  };
734 
739  class CORE_EXPORT NodeSelect : public QgsSQLStatement::Node
740  {
741  public:
743  NodeSelect( const QList<QgsSQLStatement::NodeTableDef *> &tableList SIP_TRANSFER, const QList<QgsSQLStatement::NodeSelectedColumn *> &columns SIP_TRANSFER, bool distinct ) : mTableList( tableList ), mColumns( columns ), mDistinct( distinct ) {}
744  ~NodeSelect() override;
745 
747  void setJoins( const QList<QgsSQLStatement::NodeJoin *> &joins SIP_TRANSFER ) { qDeleteAll( mJoins ); mJoins = joins; }
749  void appendJoin( QgsSQLStatement::NodeJoin *join SIP_TRANSFER ) { mJoins.append( join ); }
751  void setWhere( QgsSQLStatement::Node *where SIP_TRANSFER ) { delete mWhere; mWhere = where; }
753  void setOrderBy( const QList<QgsSQLStatement::NodeColumnSorted *> &orderBy SIP_TRANSFER ) { qDeleteAll( mOrderBy ); mOrderBy = orderBy; }
754 
756  QList<QgsSQLStatement::NodeTableDef *> tables() const { return mTableList; }
758  QList<QgsSQLStatement::NodeSelectedColumn *> columns() const { return mColumns; }
760  bool distinct() const { return mDistinct; }
762  QList<QgsSQLStatement::NodeJoin *> joins() const { return mJoins; }
764  QgsSQLStatement::Node *where() const { return mWhere; }
766  QList<QgsSQLStatement::NodeColumnSorted *> orderBy() const { return mOrderBy; }
767 
768  QgsSQLStatement::NodeType nodeType() const override { return ntSelect; }
769  QString dump() const override;
770 
771  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
772  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
773 
774  protected:
775  QList<NodeTableDef *> mTableList;
776  QList<NodeSelectedColumn *> mColumns;
777  bool mDistinct;
778  QList<NodeJoin *> mJoins;
779  Node *mWhere = nullptr;
780  QList<NodeColumnSorted *> mOrderBy;
781  };
782 
784 
790  class CORE_EXPORT Visitor
791  {
792  public:
793  virtual ~Visitor() = default;
795  virtual void visit( const QgsSQLStatement::NodeUnaryOperator &n ) = 0;
797  virtual void visit( const QgsSQLStatement::NodeBinaryOperator &n ) = 0;
799  virtual void visit( const QgsSQLStatement::NodeInOperator &n ) = 0;
801  virtual void visit( const QgsSQLStatement::NodeBetweenOperator &n ) = 0;
803  virtual void visit( const QgsSQLStatement::NodeFunction &n ) = 0;
805  virtual void visit( const QgsSQLStatement::NodeLiteral &n ) = 0;
807  virtual void visit( const QgsSQLStatement::NodeColumnRef &n ) = 0;
809  virtual void visit( const QgsSQLStatement::NodeSelectedColumn &n ) = 0;
811  virtual void visit( const QgsSQLStatement::NodeTableDef &n ) = 0;
813  virtual void visit( const QgsSQLStatement::NodeSelect &n ) = 0;
815  virtual void visit( const QgsSQLStatement::NodeJoin &n ) = 0;
817  virtual void visit( const QgsSQLStatement::NodeColumnSorted &n ) = 0;
819  virtual void visit( const QgsSQLStatement::NodeCast &n ) = 0;
820  };
821 
826  class CORE_EXPORT RecursiveVisitor: public QgsSQLStatement::Visitor
827  {
828  public:
830  RecursiveVisitor() = default;
831 
832  void visit( const QgsSQLStatement::NodeUnaryOperator &n ) override { n.operand()->accept( *this ); }
833  void visit( const QgsSQLStatement::NodeBinaryOperator &n ) override { n.opLeft()->accept( *this ); n.opRight()->accept( *this ); }
834  void visit( const QgsSQLStatement::NodeInOperator &n ) override { n.node()->accept( *this ); n.list()->accept( *this ); }
835  void visit( const QgsSQLStatement::NodeBetweenOperator &n ) override { n.node()->accept( *this ); n.minVal()->accept( *this ); n.maxVal()->accept( *this ); }
836  void visit( const QgsSQLStatement::NodeFunction &n ) override { n.args()->accept( *this ); }
837  void visit( const QgsSQLStatement::NodeLiteral & ) override {}
838  void visit( const QgsSQLStatement::NodeColumnRef & ) override { }
839  void visit( const QgsSQLStatement::NodeSelectedColumn &n ) override { n.column()->accept( *this ); }
840  void visit( const QgsSQLStatement::NodeTableDef & ) override {}
841  void visit( const QgsSQLStatement::NodeSelect &n ) override;
842  void visit( const QgsSQLStatement::NodeJoin &n ) override;
843  void visit( const QgsSQLStatement::NodeColumnSorted &n ) override { n.column()->accept( *this ); }
844  void visit( const QgsSQLStatement::NodeCast &n ) override { n.node()->accept( *this ); }
845  };
846 
849 
850  protected:
851  QgsSQLStatement::Node *mRootNode = nullptr;
852  bool mAllowFragments = false;
853  QString mStatement;
855 
864  QgsSQLStatement( const QString &statement, bool allowFragments );
865 };
866 
868 
869 
874 class CORE_EXPORT QgsSQLStatementFragment : public QgsSQLStatement
875 {
876  public:
877 
881  QgsSQLStatementFragment( const QString &fragment );
882 
883 };
884 
885 
886 #endif // QGSSQLSTATEMENT_H
QgsSQLStatement::Node
Abstract node class.
Definition: qgssqlstatement.h:234
QgsSQLStatement::NodeJoin
Join definition.
Definition: qgssqlstatement.h:683
QgsSQLStatement::QgsSQLStatement
QgsSQLStatement(const QString &statement)
Creates a new statement based on the provided string.
Definition: qgssqlstatement.cpp:130
QgsSQLStatement::NodeColumnSorted
Column in a ORDER BY.
Definition: qgssqlstatement.h:723
QgsSQLStatement::NodeUnaryOperator::operand
QgsSQLStatement::Node * operand() const
Operand.
Definition: qgssqlstatement.h:354
QgsSQLStatement::NodeBinaryOperator::opLeft
QgsSQLStatement::Node * opLeft() const
Left operand.
Definition: qgssqlstatement.h:386
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsSQLStatement::Visitor::visit
virtual void visit(const QgsSQLStatement::NodeUnaryOperator &n)=0
Visit NodeUnaryOperator.
QgsSQLStatement::NodeTableDef
Table definition.
Definition: qgssqlstatement.h:638
QgsSQLStatement::NodeFunction
Function with a name and arguments node.
Definition: qgssqlstatement.h:483
QgsSQLStatement::acceptVisitor
void acceptVisitor(QgsSQLStatement::Visitor &v) const
Entry function for the visitor pattern.
Definition: qgssqlstatement.cpp:169
QgsSQLStatement::ntTableDef
@ ntTableDef
Definition: qgssqlstatement.h:224
QgsSQLStatement::NodeSelect
SELECT node.
Definition: qgssqlstatement.h:753
QgsSQLStatement::NodeCast
CAST operator.
Definition: qgssqlstatement.h:610
QgsSQLStatement::NodeUnaryOperator
Unary logicial/arithmetical operator ( NOT, - )
Definition: qgssqlstatement.h:343
QgsSQLStatement::ntFunction
@ ntFunction
Definition: qgssqlstatement.h:219
QgsSQLStatement::ntInOperator
@ ntInOperator
Definition: qgssqlstatement.h:217
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSQLStatement::NodeColumnSorted::column
QgsSQLStatement::NodeColumnRef * column() const
The name of the column.
Definition: qgssqlstatement.h:731
QgsSQLStatement::NodeSelectedColumn::column
QgsSQLStatement::Node * column() const
Column that is referred to.
Definition: qgssqlstatement.h:588
QgsSQLStatement::ntCast
@ ntCast
Definition: qgssqlstatement.h:227
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
QgsSQLStatement::Visitor
Support for visitor pattern - algorithms dealing with the statement may be implemented without modify...
Definition: qgssqlstatement.h:804
QgsSQLStatement::ntBinaryOperator
@ ntBinaryOperator
Definition: qgssqlstatement.h:216
QgsSQLStatement::ntSelectedColumn
@ ntSelectedColumn
Definition: qgssqlstatement.h:222
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsSQLStatement::NodeInOperator::node
QgsSQLStatement::Node * node() const
Variable at the left of IN.
Definition: qgssqlstatement.h:422
QgsSQLStatement::ntLiteral
@ ntLiteral
Definition: qgssqlstatement.h:220
QgsSQLStatement::mParserErrorString
QString mParserErrorString
Definition: qgssqlstatement.h:868
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsSQLStatement::ntColumnSorted
@ ntColumnSorted
Definition: qgssqlstatement.h:226
QgsSQLStatement
Class for parsing SQL statements.
Definition: qgssqlstatement.h:35
QgsSQLStatement::ntSelect
@ ntSelect
Definition: qgssqlstatement.h:223
QgsSQLStatement::NodeBinaryOperator::opRight
QgsSQLStatement::Node * opRight() const
Right operand.
Definition: qgssqlstatement.h:389
QgsSQLStatement::NodeFunction::args
QgsSQLStatement::NodeList * args() const
Returns arguments.
Definition: qgssqlstatement.h:494
QgsSQLStatement::NodeBetweenOperator::node
QgsSQLStatement::Node * node() const
Variable at the left of BETWEEN.
Definition: qgssqlstatement.h:455
QgsSQLStatement::NodeType
NodeType
Node type.
Definition: qgssqlstatement.h:213
QgsSQLStatement::JoinType
JoinType
list of join types
Definition: qgssqlstatement.h:187
QgsSQLStatement::NodeInOperator
'x IN (y, z)' operator
Definition: qgssqlstatement.h:414
QgsSQLStatement::NodeBinaryOperator
Binary logical/arithmetical operator (AND, OR, =, +, ...)
Definition: qgssqlstatement.h:371
QgsSQLStatement::NodeBetweenOperator::maxVal
QgsSQLStatement::Node * maxVal() const
Maximum bound.
Definition: qgssqlstatement.h:464
QgsSQLStatement::NodeColumnRef
Reference to a column.
Definition: qgssqlstatement.h:535
QgsSQLStatement::NodeList
A list of nodes.
Definition: qgssqlstatement.h:308
QgsSQLStatement::Node::accept
virtual void accept(QgsSQLStatement::Visitor &v) const =0
Support the visitor pattern.
QgsSQLStatement::UnaryOperator
UnaryOperator
list of unary operators
Definition: qgssqlstatement.h:140
QgsSQLStatement::NodeCast::node
QgsSQLStatement::Node * node() const
Node that is referred to.
Definition: qgssqlstatement.h:618
QgsSQLStatement::mStatement
QString mStatement
Definition: qgssqlstatement.h:867
QgsSQLStatement::ntJoin
@ ntJoin
Definition: qgssqlstatement.h:225
QgsSQLStatement::NodeColumnRef::accept
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
Definition: qgssqlstatement.h:561
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QgsSQLStatementFragment
Class for parsing fragments of SQL statements, such as an expression or where clause.
Definition: qgssqlstatement.h:874
QgsSQLStatement::ntBetweenOperator
@ ntBetweenOperator
Definition: qgssqlstatement.h:218
QgsSQLStatement::ntColumnRef
@ ntColumnRef
Definition: qgssqlstatement.h:221
QgsSQLStatement::BinaryOperator
BinaryOperator
list of binary operators
Definition: qgssqlstatement.h:150
QgsSQLStatement::ntUnaryOperator
@ ntUnaryOperator
Definition: qgssqlstatement.h:215
QgsSQLStatement::RecursiveVisitor
A visitor that recursively explores all children.
Definition: qgssqlstatement.h:840
QgsSQLStatement::NodeList::accept
void accept(QgsSQLStatement::Visitor &v) const
Accept visitor.
Definition: qgssqlstatement.cpp:277
QgsSQLStatement::NodeInOperator::list
QgsSQLStatement::NodeList * list() const
Values list.
Definition: qgssqlstatement.h:428
QgsSQLStatement::NodeSelectedColumn
Selected column.
Definition: qgssqlstatement.h:577
QgsSQLStatement::NodeBetweenOperator::minVal
QgsSQLStatement::Node * minVal() const
Minimum bound.
Definition: qgssqlstatement.h:461
QgsSQLStatement::NodeBetweenOperator
'X BETWEEN y and z' operator
Definition: qgssqlstatement.h:446
SIP_END
#define SIP_END
Definition: qgis_sip.h:203
QgsSQLStatement::NodeLiteral
Literal value (integer, integer64, double, string)
Definition: qgssqlstatement.h:512