QgsSQLStatement class
Class for parsing SQL statements.
Contents
Public types
- class Node
- Abstract node class.
- class NodeBetweenOperator
- 'X BETWEEN y and z' operator
- class NodeBinaryOperator
- Binary logical/arithmetical operator (AND, OR, =, +, ...)
- class NodeCast
- CAST operator.
- class NodeColumnRef
- Reference to a column.
- class NodeColumnSorted
- Column in a ORDER BY.
- class NodeFunction
- Function with a name and arguments node.
- class NodeInOperator
- 'x IN (y, z)' operator
- class NodeJoin
- Join definition.
- class NodeList
- A list of nodes.
- class NodeLiteral
- Literal value (integer, integer64, double, string)
- class NodeSelect
- SELECT node.
- class NodeSelectedColumn
- Selected column.
- class NodeTableDef
- Table definition.
- class NodeUnaryOperator
- Unary logicial/arithmetical operator ( NOT, - )
- class RecursiveVisitor
- A visitor that recursively explores all children.
- class Visitor
- Support for visitor pattern - algorithms dealing with the statement may be implemented without modifying the Node classes.
- enum BinaryOperator { boOr, boAnd, boEQ, boNE, boLE, boGE, boLT, boGT, boLike, boNotLike, boILike, boNotILike, boIs, boIsNot, boPlus, boMinus, boMul, boDiv, boIntDiv, boMod, boPow, boConcat }
- list of binary operators
- enum JoinType { jtDefault, jtLeft, jtLeftOuter, jtRight, jtRightOuter, jtCross, jtInner, jtFull }
- list of join types
- enum NodeType { ntUnaryOperator, ntBinaryOperator, ntInOperator, ntBetweenOperator, ntFunction, ntLiteral, ntColumnRef, ntSelectedColumn, ntSelect, ntTableDef, ntJoin, ntColumnSorted, ntCast }
- Node type.
- enum UnaryOperator { uoNot, uoMinus }
- list of unary operators
Public static variables
- static const char* BINARY_OPERATOR_TEXT
- static const char* JOIN_TYPE_TEXT
- static const char* UNARY_OPERATOR_TEXT
Public static functions
- static auto quotedIdentifier(QString name) -> QString
- Returns a quoted column reference (in double quotes)
- static auto quotedIdentifierIfNeeded(const QString& name) -> QString
- Returns a quoted column reference (in double quotes) if needed, or otherwise the original string.
- static auto quotedString(QString text) -> QString
- Returns a quoted version of a string (in single quotes)
- static auto stripQuotedIdentifier(QString text) -> QString
- Remove double quotes from an identifier.
Constructors, destructors, conversion operators
- QgsSQLStatement(const QString& statement)
- Creates a new statement based on the provided string.
- QgsSQLStatement(const QgsSQLStatement& other)
- Create a copy of this statement.
Public functions
-
void acceptVisitor(QgsSQLStatement::
Visitor& v) const - Entry function for the visitor pattern.
- auto doBasicValidationChecks(QString& errorMsgOut) const -> bool
- Performs basic validity checks.
- auto dump() const -> QString
- Returns the statement string, constructed from the internal abstract syntax tree.
- auto hasParserError() const -> bool
- Returns true if an error occurred when parsing the input statement.
- auto operator=(const QgsSQLStatement& other) -> QgsSQLStatement&
- Create a copy of this statement.
- auto parserErrorString() const -> QString
- Returns parser error.
-
auto rootNode() const -> const QgsSQLStatement::
Node* - Returns root node of the statement. Root node is null is parsing has failed.
- auto statement() const -> QString
- Returns the original, unmodified statement string.
Enum documentation
enum QgsSQLStatement:: BinaryOperator
list of binary operators
enum QgsSQLStatement:: JoinType
list of join types
enum QgsSQLStatement:: UnaryOperator
list of unary operators
Function documentation
static QString QgsSQLStatement:: quotedIdentifier(QString name)
Returns a quoted column reference (in double quotes)
static QString QgsSQLStatement:: quotedIdentifierIfNeeded(const QString& name)
Returns a quoted column reference (in double quotes) if needed, or otherwise the original string.
static QString QgsSQLStatement:: quotedString(QString text)
Returns a quoted version of a string (in single quotes)
static QString QgsSQLStatement:: stripQuotedIdentifier(QString text)
Remove double quotes from an identifier.
bool QgsSQLStatement:: doBasicValidationChecks(QString& errorMsgOut) const
Performs basic validity checks.
Basically checking that columns referencing a table, references a specified table. Returns true if the validation is successful
QString QgsSQLStatement:: dump() const
Returns the statement string, constructed from the internal abstract syntax tree.
This does not contain any nice whitespace formatting or comments. In general it is preferable to use statement() instead.