Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2947 from rouault/minmax_longlong
Make QgsVectorDataProvider::fillMinMaxCache() handle LongLong
  • Loading branch information
m-kuhn committed Mar 27, 2016
2 parents fbf4d67 + 6ac1398 commit 060019c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/core/qgsvectordataprovider.cpp
Expand Up @@ -18,6 +18,7 @@

#include <cfloat> // for DBL_MAX
#include <climits>
#include <limits>

#include "qgsvectordataprovider.h"
#include "qgsfeature.h"
Expand Down Expand Up @@ -393,6 +394,11 @@ void QgsVectorDataProvider::fillMinMaxCache()
mCacheMinValues[i] = QVariant( INT_MAX );
mCacheMaxValues[i] = QVariant( INT_MIN );
}
else if ( flds[i].type() == QVariant::LongLong )
{
mCacheMinValues[i] = QVariant( std::numeric_limits<qlonglong>::max() );
mCacheMaxValues[i] = QVariant( std::numeric_limits<qlonglong>::min() );
}
else if ( flds[i].type() == QVariant::Double )
{
mCacheMinValues[i] = QVariant( DBL_MAX );
Expand Down Expand Up @@ -427,6 +433,14 @@ void QgsVectorDataProvider::fillMinMaxCache()
if ( value > mCacheMaxValues[*it].toInt() )
mCacheMaxValues[*it] = value;
}
else if ( flds[*it].type() == QVariant::LongLong )
{
qlonglong value = varValue.toLongLong();
if ( value < mCacheMinValues[*it].toLongLong() )
mCacheMinValues[*it] = value;
if ( value > mCacheMaxValues[*it].toLongLong() )
mCacheMaxValues[*it] = value;
}
else if ( flds[*it].type() == QVariant::Double )
{
double value = varValue.toDouble();
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_memory.py
Expand Up @@ -271,7 +271,7 @@ class TestPyQgsMemoryProviderIndexed(unittest.TestCase, ProviderTestCase):
def setUpClass(cls):
"""Run before all tests"""
# Create test layer
cls.vl = QgsVectorLayer(u'Point?crs=epsg:4326&index=yes&field=pk:integer&field=cnt:integer&field=name:string(0)&field=name2:string(0)&field=num_char:string&key=pk',
cls.vl = QgsVectorLayer(u'Point?crs=epsg:4326&index=yes&field=pk:integer&field=cnt:int8&field=name:string(0)&field=name2:string(0)&field=num_char:string&key=pk',
u'test', u'memory')
assert (cls.vl.isValid())
cls.provider = cls.vl.dataProvider()
Expand Down

0 comments on commit 060019c

Please sign in to comment.