Skip to content

Commit 84a8219

Browse files
committed
[mssql] Small fixes to expression compilation
- Use [] to correctly quote field names instead of "" - Don't invalidate provider side limit when not required Forward port of 8dec70c, because I'm only human and forgot
1 parent 794583e commit 84a8219

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/providers/mssql/qgsmssqlexpressioncompiler.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ QString QgsMssqlExpressionCompiler::quotedValue( const QVariant &value, bool &ok
9191
}
9292
}
9393

94+
QString QgsMssqlExpressionCompiler::quotedIdentifier( const QString &identifier )
95+
{
96+
QString quoted = identifier;
97+
quoted.replace( '[', "[[" );
98+
quoted.replace( ']', "]]" );
99+
quoted = quoted.prepend( '[' ).append( ']' );
100+
return quoted;
101+
}
102+
94103
QString QgsMssqlExpressionCompiler::castToReal( const QString &value ) const
95104
{
96105
return QStringLiteral( "CAST((%1) AS REAL)" ).arg( value );

src/providers/mssql/qgsmssqlexpressioncompiler.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class QgsMssqlExpressionCompiler : public QgsSqlExpressionCompiler
2929
protected:
3030
Result compileNode( const QgsExpressionNode *node, QString &result ) override;
3131
QString quotedValue( const QVariant &value, bool &ok ) override;
32+
QString quotedIdentifier( const QString& identifier ) override;
3233
QString castToReal( const QString &value ) const override;
3334
QString castToInt( const QString &value ) const override;
3435
QString sqlFunctionFromFunctionName( const QString &fnName ) const override;

src/providers/mssql/qgsmssqlfeatureiterator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest &request )
265265
mOrderByCompiled = false;
266266
}
267267

268-
if ( !mOrderByCompiled )
268+
if ( !mOrderByCompiled && !request.orderBy().isEmpty() )
269269
limitAtProvider = false;
270270

271271
if ( request.limit() >= 0 && limitAtProvider )

0 commit comments

Comments
 (0)