Skip to content
Permalink
Browse files
readd lines lost during merge
  • Loading branch information
domi4484 committed Aug 17, 2021
1 parent d94bcbc commit d6df5312ef6fd7c0b9dc51c755a3f235c84a9a24
Showing with 9 additions and 15 deletions.
  1. +8 −2 src/core/providers/memory/qgsmemoryprovider.cpp
  2. +1 −13 tests/src/python/test_provider_memory.py
@@ -527,7 +527,7 @@ bool QgsMemoryProvider::deleteFeatures( const QgsFeatureIds &id )

bool QgsMemoryProvider::addAttributes( const QList<QgsField> &attributes )
{
for ( QList<QgsField>::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
for ( QgsField field : attributes )
{
if ( !supportedType( field ) )
continue;
@@ -538,6 +538,12 @@ bool QgsMemoryProvider::addAttributes( const QList<QgsField> &attributes )
const QList<QgsVectorDataProvider::NativeType> nativeTypesList( nativeTypes() );
for ( const NativeType &nativeType : nativeTypesList )
{
if ( nativeType.mTypeName.toLower() == field.typeName().toLower() )
{
isNativeTypeName = true;
break;
}

if ( nativeType.mType == field.type()
&& nativeTypeCandidate.mType == QVariant::Invalid )
nativeTypeCandidate = nativeType;
@@ -555,7 +561,7 @@ bool QgsMemoryProvider::addAttributes( const QList<QgsField> &attributes )
}

// add new field as a last one
mFields.append( *it );
mFields.append( field );

for ( QgsFeatureMap::iterator fit = mFeatures.begin(); fit != mFeatures.end(); ++fit )
{
@@ -841,10 +841,7 @@ def testAddAttributes(self):
QgsField("short", QVariant.Int, "int2"),
QgsField("lessshort", QVariant.Int, "int4"),
QgsField("numericfield", QVariant.Double, "numeric"),
QgsField("decimalfield", QVariant.Double, "decimal"),
QgsField("stringlistfield", QVariant.StringList, "stringlist"),
QgsField("integerlistfield", QVariant.List, "integerlist"),
QgsField("doublelistfield", QVariant.List, "doublelist")])
QgsField("decimalfield", QVariant.Double, "decimal")])

self.assertEqual(pr.fields()[0].typeName(), "string")
self.assertEqual(pr.fields()[1].typeName(), "integer")
@@ -855,9 +852,6 @@ def testAddAttributes(self):
self.assertEqual(pr.fields()[6].typeName(), "int4")
self.assertEqual(pr.fields()[7].typeName(), "numeric")
self.assertEqual(pr.fields()[8].typeName(), "decimal")
self.assertEqual(pr.fields()[9].typeName(), "stringlist")
self.assertEqual(pr.fields()[10].typeName(), "integerlist")
self.assertEqual(pr.fields()[11].typeName(), "doublelist")

vl2 = vl.clone()

@@ -870,9 +864,6 @@ def testAddAttributes(self):
self.assertEqual(pr.fields()[6].name(), vl2.fields()[6].name())
self.assertEqual(pr.fields()[7].name(), vl2.fields()[7].name())
self.assertEqual(pr.fields()[8].name(), vl2.fields()[8].name())
self.assertEqual(pr.fields()[9].name(), vl2.fields()[9].name())
self.assertEqual(pr.fields()[10].name(), vl2.fields()[10].name())
self.assertEqual(pr.fields()[11].name(), vl2.fields()[11].name())

self.assertEqual(pr.fields()[0].typeName(), vl2.fields()[0].typeName())
self.assertEqual(pr.fields()[1].typeName(), vl2.fields()[1].typeName())
@@ -883,9 +874,6 @@ def testAddAttributes(self):
self.assertEqual(pr.fields()[6].typeName(), vl2.fields()[6].typeName())
self.assertEqual(pr.fields()[7].typeName(), vl2.fields()[7].typeName())
self.assertEqual(pr.fields()[8].typeName(), vl2.fields()[8].typeName())
self.assertEqual(pr.fields()[9].typeName(), vl2.fields()[9].typeName())
self.assertEqual(pr.fields()[10].typeName(), vl2.fields()[10].typeName())
self.assertEqual(pr.fields()[11].typeName(), vl2.fields()[11].typeName())


class TestPyQgsMemoryProviderIndexed(unittest.TestCase, ProviderTestCase):

0 comments on commit d6df531

Please sign in to comment.