Add patch for upstream issue #14402 (MSSQL)

This commit is contained in:
Volker Fröhlich 2016-03-09 01:45:15 +01:00
parent 5db6321f57
commit cd34dd3725
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,43 @@
From 30449e577f0cd432bd8c60787743fba54c1e51b9 Mon Sep 17 00:00:00 2001
From: Nyall Dawson <nyall.dawson@gmail.com>
Date: Thu, 3 Mar 2016 10:34:32 +1100
Subject: [PATCH] Fix fetching subset of attributes with mssql (fix #14402),
add test
---
src/providers/mssql/qgsmssqlfeatureiterator.cpp | 2 +-
tests/src/python/providertestbase.py | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/providers/mssql/qgsmssqlfeatureiterator.cpp b/src/providers/mssql/qgsmssqlfeatureiterator.cpp
index 53214d4..560d344 100644
--- a/src/providers/mssql/qgsmssqlfeatureiterator.cpp
+++ b/src/providers/mssql/qgsmssqlfeatureiterator.cpp
@@ -284,7 +284,7 @@ bool QgsMssqlFeatureIterator::fetchFeature( QgsFeature& feature )
for ( int i = 0; i < mAttributesToFetch.count(); i++ )
{
QVariant v = mQuery->value( i );
- const QgsField &fld = mSource->mFields.at( i );
+ const QgsField &fld = mSource->mFields.at( mAttributesToFetch.at( i ) );
if ( v.type() != fld.type() )
v = QgsVectorDataProvider::convertValue( fld.type(), v.toString() );
feature.setAttribute( mAttributesToFetch.at( i ), v );
diff --git a/tests/src/python/providertestbase.py b/tests/src/python/providertestbase.py
index 7b8707e..26e6d86 100644
--- a/tests/src/python/providertestbase.py
+++ b/tests/src/python/providertestbase.py
@@ -384,3 +384,14 @@ def testClosedIterators(self):
# Test rewinding closed iterator
self.assertFalse(f_it.rewind(), 'Rewinding closed iterator successful, should not be allowed')
+
+ def testGetFeaturesSubsetAttributes(self):
+ """ Test that expected results are returned when using subsets of attributes """
+
+ tests = {'pk': set([1, 2, 3, 4, 5]),
+ 'cnt': set([-200, 300, 100, 200, 400]),
+ 'name': set(['Pear', 'Orange', 'Apple', 'Honey', NULL]),
+ 'name2': set(['NuLl', 'PEaR', 'oranGe', 'Apple', 'Honey'])}
+ for field, expected in tests.iteritems():
+ result = set([f[field] for f in self.provider.getFeatures(QgsFeatureRequest().setSubsetOfAttributes([field], self.provider.fields()))])
+ self.assertEqual(result, expected, 'Expected {}, got {}'.format(expected, result))

View File

@ -15,7 +15,7 @@
Name: qgis
Version: 2.14.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A user friendly Open Source Geographic Information System
Group: Applications/Engineering
@ -35,6 +35,9 @@ Source4: %{name}-server-README.fedora
# Based on debian/qgis.xml but excluding already defined or proprietary types
Source5: %{name}-mime.xml
https://github.com/qgis/QGIS/commit/30449e577f0cd432bd8c60787743fba54c1e51b9.patch
Patch0: %{name}-2.14.0-mssql-attributes.patch
# Some plug-ins need Pyspatialite (bundled)
# The license is not totally clear, see:
# http://code.google.com/p/pyspatialite/issues/detail?id=3
@ -177,6 +180,8 @@ Please refer to %{name}-server-README.fedora for details!
%prep
%setup -q
%patch0 -p1 -b .~mssql
# Remove executable permissions from source code files
find . \( -name "*.cpp" -o -name "*.h" \) -type f -perm /111 -execdir chmod -x {} \+
@ -403,6 +408,9 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%changelog
* Tue Mar 9 2016 Volker Froehlich <volker27@gmx.at> - 2.14.0-2
- Add patch for upstream issue #14402 (MSSQL)
* Sat Feb 27 2016 Volker Froehlich <volker27@gmx.at> - 2.14.0-1
- New upstream release
- Add PyYAML as BR and disable the use of the bundled version