22 QgsSQLiteExpressionCompiler::QgsSQLiteExpressionCompiler(
const QgsFields &fields )
33 switch ( static_cast<const QgsExpressionNodeBinaryOperator *>( node )->op() )
52 QString QgsSQLiteExpressionCompiler::quotedIdentifier(
const QString &identifier )
54 QString id( identifier );
55 id.replace(
'\"', QLatin1String(
"\"\"" ) );
56 return id.prepend(
'\"' ).append(
'\"' );
59 QString QgsSQLiteExpressionCompiler::quotedValue(
const QVariant &value,
bool &ok )
64 return QStringLiteral(
"NULL" );
66 switch ( value.type() )
69 case QVariant::LongLong:
70 case QVariant::Double:
71 return value.toString();
75 return value.toBool() ?
"1" :
"0";
78 case QVariant::String:
79 QString v = value.toString();
84 return v.replace(
'\'', QLatin1String(
"''" ) ).prepend(
'\'' ).append(
'\'' );
88 QString QgsSQLiteExpressionCompiler::sqlFunctionFromFunctionName(
const QString &fnName )
const 90 static const QMap<QString, QString> FN_NAMES
94 {
"coalesce",
"coalesce" },
101 return FN_NAMES.value( fnName, QString() );
104 QString QgsSQLiteExpressionCompiler::castToReal(
const QString &value )
const 106 return QStringLiteral(
"CAST((%1) AS REAL)" ).arg( value );
109 QString QgsSQLiteExpressionCompiler::castToInt(
const QString &value )
const 111 return QStringLiteral(
"CAST((%1) AS INTEGER)" ).arg( value );
114 QString QgsSQLiteExpressionCompiler::castToText(
const QString &value )
const 116 return QStringLiteral(
"CAST((%1) AS TEXT)" ).arg( value );
Container of fields for a vector layer.
Provider cannot handle expression.
Abstract base class for all nodes that can appear in an expression.
Generic expression compiler for translation to provider specific SQL WHERE clauses.
Result
Possible results from expression compilation.
virtual Result compileNode(const QgsExpressionNode *node, QString &str)
Compiles an expression node and returns the result of the compilation.
virtual QString result()
Returns the compiled expression string for use by the provider.
virtual QgsExpressionNode::NodeType nodeType() const =0
Gets the type of this node.