Skip to content
Permalink
Browse files

[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
  • Loading branch information
nyalldawson committed May 29, 2017
1 parent 794583e commit 84a821915e41f565b36f95d3afcc47bc0132e64b
@@ -91,6 +91,15 @@ QString QgsMssqlExpressionCompiler::quotedValue( const QVariant &value, bool &ok
}
}

QString QgsMssqlExpressionCompiler::quotedIdentifier( const QString &identifier )
{
QString quoted = identifier;
quoted.replace( '[', "[[" );
quoted.replace( ']', "]]" );
quoted = quoted.prepend( '[' ).append( ']' );
return quoted;
}

QString QgsMssqlExpressionCompiler::castToReal( const QString &value ) const
{
return QStringLiteral( "CAST((%1) AS REAL)" ).arg( value );
@@ -29,6 +29,7 @@ class QgsMssqlExpressionCompiler : public QgsSqlExpressionCompiler
protected:
Result compileNode( const QgsExpressionNode *node, QString &result ) override;
QString quotedValue( const QVariant &value, bool &ok ) override;
QString quotedIdentifier( const QString& identifier ) override;
QString castToReal( const QString &value ) const override;
QString castToInt( const QString &value ) const override;
QString sqlFunctionFromFunctionName( const QString &fnName ) const override;
@@ -265,7 +265,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest &request )
mOrderByCompiled = false;
}

if ( !mOrderByCompiled )
if ( !mOrderByCompiled && !request.orderBy().isEmpty() )
limitAtProvider = false;

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

0 comments on commit 84a8219

Please sign in to comment.
You can’t perform that action at this time.