Skip to content

Commit

Permalink
[mssql] Allow compilation of int div expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 5, 2018
1 parent 4a687a0 commit 1d9086c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/providers/mssql/qgsmssqlexpressioncompiler.cpp
Expand Up @@ -83,3 +83,8 @@ QString QgsMssqlExpressionCompiler::castToReal( const QString &value ) const
{
return QStringLiteral( "CAST((%1) AS REAL)" ).arg( value );
}

QString QgsMssqlExpressionCompiler::castToInt( const QString &value ) const
{
return QStringLiteral( "CAST((%1) AS integer)" ).arg( value );
}
1 change: 1 addition & 0 deletions src/providers/mssql/qgsmssqlexpressioncompiler.h
Expand Up @@ -30,6 +30,7 @@ class QgsMssqlExpressionCompiler : public QgsSqlExpressionCompiler
Result compileNode( const QgsExpressionNode *node, QString &result ) override;
QString quotedValue( const QVariant &value, bool &ok ) override;
QString castToReal( const QString &value ) const override;
QString castToInt( const QString &value ) const override;

};

Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlfeatureiterator.cpp
Expand Up @@ -122,7 +122,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest &request )
mStatement += QStringLiteral( ",[%1]" ).arg( mSource->mGeometryColName );
}

mStatement += QStringLiteral( "FROM [%1].[%2]" ).arg( mSource->mSchemaName, mSource->mTableName );
mStatement += QStringLiteral( " FROM [%1].[%2]" ).arg( mSource->mSchemaName, mSource->mTableName );

bool filterAdded = false;
// set spatial filter
Expand Down
1 change: 0 additions & 1 deletion tests/src/python/test_provider_mssql.py
Expand Up @@ -85,7 +85,6 @@ def uncompiledFilters(self):
'\'x\' || "name" IS NOT NULL',
'\'x\' || "name" IS NULL',
'"name" ~ \'[OP]ra[gne]+\'',
'pk = 9 // 4',
'false and NULL',
'true and NULL',
'NULL and false',
Expand Down

0 comments on commit 1d9086c

Please sign in to comment.