diff --git a/src/core/providers/ogr/qgsogrproviderutils.cpp b/src/core/providers/ogr/qgsogrproviderutils.cpp index 9c1b80eb3457..67b779c265c2 100644 --- a/src/core/providers/ogr/qgsogrproviderutils.cpp +++ b/src/core/providers/ogr/qgsogrproviderutils.cpp @@ -344,8 +344,13 @@ QString createFilters( const QString &type ) } else if ( driverName.startsWith( QLatin1String( "GPKG" ) ) ) { +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,7,0) + sFileFilters += createFileFilter_( QObject::tr( "GeoPackage" ), QStringLiteral( "*.gpkg *.gpkg.zip" ) ); + sExtensions << QStringLiteral( "gpkg" ) << QStringLiteral( "gpkg.zip" ); +#else sFileFilters += createFileFilter_( QObject::tr( "GeoPackage" ), QStringLiteral( "*.gpkg" ) ); sExtensions << QStringLiteral( "gpkg" ); +#endif } else if ( driverName.startsWith( QLatin1String( "GRASS" ) ) ) { diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 631d2acc5f23..78c9b8f24075 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -1574,7 +1574,11 @@ class QgsVectorFileWriterMetadataContainer QgsVectorFileWriter::MetaData( QStringLiteral( "GeoPackage" ), QObject::tr( "GeoPackage" ), +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,7,0) + QStringLiteral( "*.gpkg *.gpkg.zip" ), +#else QStringLiteral( "*.gpkg" ), +#endif QStringLiteral( "gpkg" ), datasetOptions, layerOptions, diff --git a/tests/src/python/test_qgsvectorfilewriter.py b/tests/src/python/test_qgsvectorfilewriter.py index a1a2f6dcbffe..857fae26f145 100644 --- a/tests/src/python/test_qgsvectorfilewriter.py +++ b/tests/src/python/test_qgsvectorfilewriter.py @@ -903,9 +903,18 @@ def testSupportedFiltersAndFormat(self): formats = QgsVectorFileWriter.supportedFiltersAndFormats( QgsVectorFileWriter.VectorFormatOption.SortRecommended ) - self.assertEqual(formats[0].filterString, "GeoPackage (*.gpkg *.GPKG)") + if int(gdal.VersionInfo("VERSION_NUM")) >= GDAL_COMPUTE_VERSION(3, 7, 0): + self.assertEqual( + formats[0].filterString, + "GeoPackage (*.gpkg *.gpkg.zip *.GPKG *.GPKG.ZIP)", + ) + else: + self.assertEqual(formats[0].filterString, "GeoPackage (*.gpkg *.GPKG)") self.assertEqual(formats[0].driverName, "GPKG") - self.assertEqual(formats[0].globs, ["*.gpkg"]) + if int(gdal.VersionInfo("VERSION_NUM")) >= GDAL_COMPUTE_VERSION(3, 7, 0): + self.assertEqual(formats[0].globs, ["*.gpkg", "*.gpkg.zip"]) + else: + self.assertEqual(formats[0].globs, ["*.gpkg"]) self.assertEqual(formats[1].filterString, "ESRI Shapefile (*.shp *.SHP)") self.assertEqual(formats[1].driverName, "ESRI Shapefile") self.assertEqual(formats[1].globs, ["*.shp"])