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;
246 virtual ~
Node() =
default;
260 virtual QString dump()
const = 0;
294 class CORE_EXPORT NodeList
298 NodeList() =
default;
299 virtual ~NodeList() { qDeleteAll( mList ); }
305 QList<QgsSQLStatement::Node *> list() {
return mList; }
310 int count()
const {
return mList.count(); }
319 virtual QString dump() const;
343 QString dump()
const override;
350 Node *mOperand =
nullptr;
364 , mOpRight( opRight )
378 QString dump()
const override;
384 int precedence() const;
387 bool leftAssociative() const;
392 Node *mOpLeft =
nullptr;
393 Node *mOpRight =
nullptr;
411 bool isNotIn()
const {
return mNotIn; }
417 QString dump()
const override;
423 Node *mNode =
nullptr;
437 : mNode( node ), mMinVal( minVal ), mMaxVal( maxVal ), mNotBetween( notBetween ) {}
444 bool isNotBetween()
const {
return mNotBetween; }
453 QString dump()
const override;
459 Node *mNode =
nullptr;
460 Node *mMinVal =
nullptr;
477 QString name()
const {
return mName; }
483 QString dump()
const override;
502 NodeLiteral(
const QVariant &value ) : mValue( value ) {}
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; }
533 QString tableName()
const {
return mTableName; }
536 QString name()
const {
return mName; }
539 bool star()
const {
return mStar; }
542 bool distinct()
const {
return mDistinct; }
545 QString dump()
const override;
571 void setAlias(
const QString &alias ) { mAlias = alias; }
577 QString alias()
const {
return mAlias; }
580 QString dump()
const override;
601 ~
NodeCast()
override {
delete mNode; }
607 QString type()
const {
return mType; }
610 QString dump()
const override;
616 Node *mNode =
nullptr;
630 NodeTableDef(
const QString &name,
const QString &alias ) : mName( name ), mAlias( alias ) {}
636 NodeTableDef(
const QString &schema,
const QString &name,
const QString &alias ) : mName( name ), mSchema( schema ), mAlias( alias ) {}
639 QString name()
const {
return mName; }
646 QString schema()
const {
return mSchema; }
649 QString alias()
const {
return mAlias; }
652 QString dump()
const override;
676 ~
NodeJoin()
override {
delete mTableDef;
delete mOnExpr; }
685 QList<QString> usingColumns()
const {
return mUsingColumns; }
691 QString dump()
const override;
700 Node *mOnExpr =
nullptr;
701 QList<QString> mUsingColumns;
720 bool ascending()
const {
return mAsc; }
723 QString dump()
const override;
743 NodeSelect(
const QList<QgsSQLStatement::NodeTableDef *> &tableList
SIP_TRANSFER,
const QList<QgsSQLStatement::NodeSelectedColumn *> &columns
SIP_TRANSFER,
bool distinct ) : mTableList( tableList ), mColumns( columns ), mDistinct( distinct ) {}
747 void setJoins(
const QList<QgsSQLStatement::NodeJoin *> &joins
SIP_TRANSFER ) { qDeleteAll( mJoins ); mJoins = joins; }
753 void setOrderBy(
const QList<QgsSQLStatement::NodeColumnSorted *> &orderBy
SIP_TRANSFER ) { qDeleteAll( mOrderBy ); mOrderBy = orderBy; }
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; }
766 QList<QgsSQLStatement::NodeColumnSorted *> orderBy()
const {
return mOrderBy; }
769 QString dump()
const override;
779 Node *mWhere =
nullptr;
852 bool mAllowFragments =
false;
886 #endif // QGSSQLSTATEMENT_H