17 #ifndef QGSSQLSTATEMENT_H
18 #define QGSSQLSTATEMENT_H
20 #include <QCoreApplication>
23 #include <QStringList>
28 #include "qgis_core.h"
58 bool hasParserError()
const;
60 QString parserErrorString()
const;
67 bool doBasicValidationChecks( QString &errorMsgOut
SIP_OUT )
const;
82 QString statement()
const;
96 static QString quotedIdentifier( QString name );
103 static QString quotedIdentifierIfNeeded(
const QString &name );
109 static QString stripQuotedIdentifier( QString text );
115 static QString quotedString( QString text );
181 static const char *BINARY_OPERATOR_TEXT[]
SIP_SKIP;
220 switch ( sipCpp->nodeType() )
235 default: sipType = 0;
break;
241 virtual ~
Node() =
default;
255 virtual QString dump()
const = 0;
289 class CORE_EXPORT NodeList
293 NodeList() =
default;
294 virtual ~NodeList() { qDeleteAll( mList ); }
300 QList<QgsSQLStatement::Node *> list() {
return mList; }
305 int count()
const {
return mList.count(); }
314 virtual QString dump() const;
338 QString dump()
const override;
345 Node *mOperand =
nullptr;
359 , mOpRight( opRight )
373 QString dump()
const override;
379 int precedence() const;
382 bool leftAssociative() const;
387 Node *mOpLeft =
nullptr;
388 Node *mOpRight =
nullptr;
406 bool isNotIn()
const {
return mNotIn; }
412 QString dump()
const override;
418 Node *mNode =
nullptr;
432 : mNode( node ), mMinVal( minVal ), mMaxVal( maxVal ), mNotBetween( notBetween ) {}
439 bool isNotBetween()
const {
return mNotBetween; }
448 QString dump()
const override;
454 Node *mNode =
nullptr;
455 Node *mMinVal =
nullptr;
472 QString name()
const {
return mName; }
478 QString dump()
const override;
497 NodeLiteral(
const QVariant &value ) : mValue( value ) {}
500 inline QVariant value()
const {
return mValue; }
503 QString dump()
const override;
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 ) {}
525 void setDistinct(
bool distinct =
true ) { mDistinct = distinct; }
528 QString tableName()
const {
return mTableName; }
531 QString name()
const {
return mName; }
534 bool star()
const {
return mStar; }
537 bool distinct()
const {
return mDistinct; }
540 QString dump()
const override;
566 void setAlias(
const QString &alias ) { mAlias = alias; }
572 QString alias()
const {
return mAlias; }
575 QString dump()
const override;
596 ~
NodeCast()
override {
delete mNode; }
602 QString type()
const {
return mType; }
605 QString dump()
const override;
611 Node *mNode =
nullptr;
625 NodeTableDef(
const QString &name,
const QString &alias ) : mName( name ), mAlias( alias ) {}
628 QString name()
const {
return mName; }
631 QString alias()
const {
return mAlias; }
634 QString dump()
const override;
657 ~
NodeJoin()
override {
delete mTableDef;
delete mOnExpr; }
666 QList<QString> usingColumns()
const {
return mUsingColumns; }
672 QString dump()
const override;
681 Node *mOnExpr =
nullptr;
682 QList<QString> mUsingColumns;
701 bool ascending()
const {
return mAsc; }
704 QString dump()
const override;
724 NodeSelect(
const QList<QgsSQLStatement::NodeTableDef *> &tableList
SIP_TRANSFER,
const QList<QgsSQLStatement::NodeSelectedColumn *> &columns
SIP_TRANSFER,
bool distinct ) : mTableList( tableList ), mColumns( columns ), mDistinct( distinct ) {}
728 void setJoins(
const QList<QgsSQLStatement::NodeJoin *> &joins
SIP_TRANSFER ) { qDeleteAll( mJoins ); mJoins = joins; }
734 void setOrderBy(
const QList<QgsSQLStatement::NodeColumnSorted *> &orderBy
SIP_TRANSFER ) { qDeleteAll( mOrderBy ); mOrderBy = orderBy; }
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; }
747 QList<QgsSQLStatement::NodeColumnSorted *> orderBy()
const {
return mOrderBy; }
750 QString dump()
const override;
760 Node *mWhere =
nullptr;
839 #endif // QGSSQLSTATEMENT_H