diff --git a/src/providers/wfs/qgswfsprovider.cpp b/src/providers/wfs/qgswfsprovider.cpp index 00aa2bfc6be..dc732a13f87 100644 --- a/src/providers/wfs/qgswfsprovider.cpp +++ b/src/providers/wfs/qgswfsprovider.cpp @@ -978,13 +978,19 @@ bool QgsWFSProvider::deleteFeatures( const QgsFeatureIds &id ) bool QgsWFSProvider::changeGeometryValues( const QgsGeometryMap &geometry_map ) { - //find out typename from uri and strip namespace prefix + //find out typename from uri QString tname = mShared->mURI.typeName(); if ( tname.isNull() ) { return false; } + QString namespacePrefix = QgsWFSUtils::nameSpacePrefix( tname ); + if ( !namespacePrefix.isEmpty() ) + { + namespacePrefix += ':'; + } + //create xml QDomDocument transactionDoc; QDomElement transactionElem = createTransactionElement( transactionDoc ); @@ -1004,7 +1010,7 @@ bool QgsWFSProvider::changeGeometryValues( const QgsGeometryMap &geometry_map ) //Property QDomElement propertyElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Property" ) ); QDomElement nameElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Name" ) ); - QDomText nameText = transactionDoc.createTextNode( mShared->mGeometryAttribute ); + QDomText nameText = transactionDoc.createTextNode( namespacePrefix + mShared->mGeometryAttribute ); nameElem.appendChild( nameText ); propertyElem.appendChild( nameElem ); QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Value" ) ); @@ -1065,13 +1071,19 @@ QString QgsWFSProvider::convertToXML( const QVariant &value ) bool QgsWFSProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_map ) { - //find out typename from uri and strip namespace prefix + //find out typename from uri QString tname = mShared->mURI.typeName(); if ( tname.isNull() ) { return false; } + QString namespacePrefix = QgsWFSUtils::nameSpacePrefix( tname ); + if ( !namespacePrefix.isEmpty() ) + { + namespacePrefix += ':'; + } + //create xml QDomDocument transactionDoc; QDomElement transactionElem = createTransactionElement( transactionDoc ); @@ -1097,7 +1109,7 @@ bool QgsWFSProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_ QDomElement propertyElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Property" ) ); QDomElement nameElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Name" ) ); - QDomText nameText = transactionDoc.createTextNode( fieldName ); + QDomText nameText = transactionDoc.createTextNode( namespacePrefix + fieldName ); nameElem.appendChild( nameText ); propertyElem.appendChild( nameElem ); diff --git a/tests/src/python/test_provider_wfs.py b/tests/src/python/test_provider_wfs.py index da438d37603..8228a7c7ff2 100644 --- a/tests/src/python/test_provider_wfs.py +++ b/tests/src/python/test_provider_wfs.py @@ -877,13 +877,13 @@ class TestPyQgsWFSProvider(unittest.TestCase, ProviderTestCase): """ # Qt 4 order - with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=geometryProperty3,50'), 'wb') as f: + with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=my:geometryProperty3,50'), 'wb') as f: f.write(content.encode('UTF-8')) # Qt 5 order - with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=geometryProperty3,50'), 'wb') as f: + with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=my:geometryProperty3,50'), 'wb') as f: f.write(content.encode('UTF-8')) - with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=geometryProperty3,50'), 'wb') as f: + with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=my:geometryProperty3,50'), 'wb') as f: f.write(content.encode('UTF-8')) self.assertTrue(vl.dataProvider().changeGeometryValues({1: QgsGeometry.fromWkt('Point (3 50)')})) @@ -915,12 +915,12 @@ class TestPyQgsWFSProvider(unittest.TestCase, ProviderTestCase): """ # Qt 4 order - with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=intfield2longfield3stringfieldbardatetimefield2015-04-10T12:34:56.789Z'), 'wb') as f: + with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=my:intfield2my:longfield3my:stringfieldbarmy:datetimefield2015-04-10T12:34:56.789Z'), 'wb') as f: f.write(content.encode('UTF-8')) # Qt 5 order - with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=intfield2longfield3stringfieldbardatetimefield2015-04-10T12:34:56.789Z'), 'wb') as f: + with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=my:intfield2my:longfield3my:stringfieldbarmy:datetimefield2015-04-10T12:34:56.789Z'), 'wb') as f: f.write(content.encode('UTF-8')) - with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=intfield2longfield3stringfieldbardatetimefield2015-04-10T12:34:56.789Z'), 'wb') as f: + with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=my:intfield2my:longfield3my:stringfieldbarmy:datetimefield2015-04-10T12:34:56.789Z'), 'wb') as f: f.write(content.encode('UTF-8')) self.assertTrue(vl.dataProvider().changeAttributeValues({1: {0: 2, 1: 3, 2: "bar", 3: QDateTime(2015, 4, 10, 12, 34, 56, 789, Qt.TimeSpec(Qt.UTC))}}))