Skip to content

Commit

Permalink
Fix: incorrect gpkg table comment (#59626)
Browse files Browse the repository at this point in the history
* Fix: incorrect gpkg table comment

* add table comment test
  • Loading branch information
hxbb00 authored and nyalldawson committed Dec 2, 2024
1 parent 5ce97c5 commit cc42b13
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/providers/ogr/qgsgeopackageproviderconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ QList<QgsGeoPackageProviderConnection::TableProperty> 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 );
}

Expand Down
14 changes: 14 additions & 0 deletions tests/src/python/test_qgsproviderconnection_ogr_gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Binary file added tests/testdata/test_comment_layers.gpkg
Binary file not shown.

0 comments on commit cc42b13

Please sign in to comment.