From cc42b13b30d6b3bd0834414524b3c1e960279a45 Mon Sep 17 00:00:00 2001 From: hxbb00 Date: Tue, 3 Dec 2024 02:06:39 +0800 Subject: [PATCH] Fix: incorrect gpkg table comment (#59626) * Fix: incorrect gpkg table comment * add table comment test --- .../ogr/qgsgeopackageproviderconnection.cpp | 2 +- .../test_qgsproviderconnection_ogr_gpkg.py | 14 ++++++++++++++ tests/testdata/test_comment_layers.gpkg | Bin 0 -> 98304 bytes 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/testdata/test_comment_layers.gpkg diff --git a/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp b/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp index 549489a082c3..3bcb3c96f8f7 100644 --- a/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp +++ b/src/core/providers/ogr/qgsgeopackageproviderconnection.cpp @@ -271,7 +271,7 @@ QList QgsGeoPackageProviderConne property.addGeometryColumnType( QgsWkbTypes::parseType( row.at( 4 ).toString() ), crs ); } - property.setComment( row.at( 4 ).toString() ); + property.setComment( row.at( 2 ).toString() ); tableInfo.push_back( property ); } diff --git a/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py b/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py index d811dec8ebda..011f307be3b8 100644 --- a/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py +++ b/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py @@ -372,6 +372,20 @@ def test_searchLayerMetadata_buggy_extent(self): res = conn.searchLayerMetadata(QgsMetadataSearchContext()) self.assertTrue(res[0].geographicExtent().isEmpty()) + def test_table_layer_with_comment(self): + """Test a comment layer""" + gpkg_test_comment_layers_path = f'{TEST_DATA_DIR}/test_comment_layers.gpkg' + temp_comment_layers_path = f'{self.temp_dir.path()}/test_comment_layers.gpkg' + shutil.copy(gpkg_test_comment_layers_path, temp_comment_layers_path) + + md = QgsProviderRegistry.instance().providerMetadata(self.providerKey) + conn = md.createConnection(temp_comment_layers_path, {}) + + tables = conn.tables('', QgsAbstractDatabaseProviderConnection.TableFlag.Vector) + table_with_comment = tables[0] + self.assertEqual(table_with_comment.tableName(), 'table_with_comment') + self.assertEqual(table_with_comment.comment(), 'table_with_comment') + if __name__ == '__main__': unittest.main() diff --git a/tests/testdata/test_comment_layers.gpkg b/tests/testdata/test_comment_layers.gpkg new file mode 100644 index 0000000000000000000000000000000000000000..e1b423c0d510dce698e4fd3a1997e2106ef6743c GIT binary patch literal 98304 zcmeI5OK=;>d4Om50x7;E?@HK&E2#yU0Zf z3^X%bl1j=kNNKlnb#AVTQ-0(cUs6u0eDEQ;q;hahE+4!HU)HtpC6!8Cscfa3e_p^~ zW(a~0M`ZF(5d^0D@1DQE{`>Lw0MqFwaY5xtQIab;l}u9?sg4fnAt4k+4Z`akcv(jP zK6F_p@J>@y@E6+o^6Gobws8B$L2CTvi*5+%82+sm{?721!@nJ%2fov{+5hAI=e}?D zUGLuZJ?OgA@f-Sw_JsJkL11t3qHiQS*8A#`Dhs6&FPEy%OPnf{c@8Q~7Iv(+ZK0rU za)PMvvg(vsNU_ljOERh0@-mwuL1(;I9zpVmT}q}{5=*4nRE8uI?sP!{5`>K|JSM5+ z8YEbbB}kf$vkMuLipJ7xDEcUw$}l8o=tU%vsJV~IJPEpV2nNZ=f>h3_yh8GlsHk#I z5Y@ZHETvvNlFx~vq>_(#QsxzfsGB*FM1oXcBfD z%_d=o#wfDF2?clURs@mTan+6%y6XGAHvzPT5sR$P^4O_xJcWX4|e|An&eatv&``Q9hr4ZjS!+dZWRYc&Wmx z@-CN`%3Bpt(W~DX*z2xqr^vyT%@{d*^$hh))ZHrYC2){!yd;@eVqI&6^=4af2ia;G z8mo3Ot(1!0`s`{mFy3nnbVZul>=vZX+pQ#eQ;%&lhHEpLg z<++pFQmn7X|7@(B!pxeG9tix?84hduQ@R*Dp z(4*S>L`ITJIZ=2C!;xhf^B+#eXC5)Pr>AafG1{F37Ou7|^Srn%f=CK{UZ~{C@UCg8=(holQVZ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