diff --git a/src/server/services/wfs/qgswfsdescribefeaturetype.cpp b/src/server/services/wfs/qgswfsdescribefeaturetype.cpp index e970fee86928..9ade6a919b37 100644 --- a/src/server/services/wfs/qgswfsdescribefeaturetype.cpp +++ b/src/server/services/wfs/qgswfsdescribefeaturetype.cpp @@ -296,7 +296,7 @@ namespace QgsWfs } else if ( attributeType == QVariant::Double ) { - if ( field.length() != 0 && field.precision() == 0 ) + if ( field.length() > 0 && field.precision() == 0 ) attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "integer" ) ); else attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "decimal" ) ); diff --git a/tests/src/python/test_qgsserver_wfs.py b/tests/src/python/test_qgsserver_wfs.py index f48b9cd64ee9..57b4fd0e234a 100644 --- a/tests/src/python/test_qgsserver_wfs.py +++ b/tests/src/python/test_qgsserver_wfs.py @@ -456,6 +456,13 @@ def test_describeFeatureType(self): self.wfs_request_compare("DescribeFeatureType", '1.1.0', "TYPENAME=does_not_exist&", 'wfs_describeFeatureType_1_1_0_typename_wrong', project_file=project_file) + def test_describeFeatureTypeVirtualFields(self): + """Test DescribeFeatureType with virtual fields: bug GH-29767""" + + project_file = "bug_gh29767_double_vfield.qgs" + self.wfs_request_compare("DescribeFeatureType", '1.1.0', "", + 'wfs_describeFeatureType_1_1_0_virtual_fields', project_file=project_file) + def test_getFeatureFeature_0_nulls(self): """Test that 0 and null in integer columns are reported correctly""" diff --git a/tests/testdata/qgis_server/bug_gh29767_double_vfield.qgs b/tests/testdata/qgis_server/bug_gh29767_double_vfield.qgs new file mode 100644 index 000000000000..0a99a26440cf --- /dev/null +++ b/tests/testdata/qgis_server/bug_gh29767_double_vfield.qgs @@ -0,0 +1,711 @@ + + + + QGIS Test Project + + + + + + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + WGS84 + true + + + + + + + + + testlayer_c0988fd7_97ca_451d_adbc_37ad6d10583a + + + + + + + + + + degrees + + 17.92123882869385909 + 30.1492204088525888 + 18.0486921925404431 + 30.25992437587047235 + + 0 + + + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + WGS84 + true + + + 0 + + + + + + + + + + + + 8.20345930703634352 + 44.90139483904469131 + 8.20354699399348775 + 44.90148252600183554 + + testlayer_c0988fd7_97ca_451d_adbc_37ad6d10583a + ./testlayer.shp + layer_with_short_name + A Layer with a short name + A Layer with an abstract + + + + testlayer + + + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + WGS84 + true + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + true + + + + + + + + + + + + + ogr + + + + + + + + + + + + + + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + id + + + + + + + + + 255 + + + + + 1 + true + + + + 0 + 2 + off + + + + + + current_layer + + + 255 + 255 + 255 + 255 + 0 + 255 + 255 + + + + testlayer_0b835118_a5d5_4255_b5dd_f42253c0a4a0 + + + + false + + + + + + WGS84 + + + m2 + meters + + + 50 + 16 + 30 + true + false + 0 + false + false + true + 0 + + + false + + + true + 2 + D + + + + + + 3452 + +proj=longlat +datum=WGS84 +no_defs + EPSG:4326 + 1 + + + + + + + + + testlayer_c0988fd7_97ca_451d_adbc_37ad6d10583a + + + 8 + 8 + + + + + + + + None + true + elpaso@itopen.it + QGIS dev team + Alessandro Pasotti + + + 1 + + 8.20315414376310059 + 44.901236559338642 + 8.204164917965862 + 44.90159838674664172 + + conditions unknown + 90 + + + + 1 + + 4 + false + + + + false + Some UTF8 text èòù + true + QGIS TestProject + + false + + + + + + + + false + + + + + false + + 5000 + + + + false + + + + + + + + + + + QGIS Test Project + + + + + + + + + + + + + 2000-01-01T00:00:00 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +