Skip to content

Commit

Permalink
Fix DB manager does not show geography in query results
Browse files Browse the repository at this point in the history
Fixes #37666
  • Loading branch information
elpaso committed Oct 3, 2020
1 parent f327256 commit ad96c99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -1067,6 +1067,7 @@ bool QgsPostgresProvider::loadFields()
else if ( fieldTypeName == QLatin1String( "text" ) ||
fieldTypeName == QLatin1String( "citext" ) ||
fieldTypeName == QLatin1String( "geometry" ) ||
fieldTypeName == QLatin1String( "geography" ) ||
fieldTypeName == QLatin1String( "inet" ) ||
fieldTypeName == QLatin1String( "money" ) ||
fieldTypeName == QLatin1String( "ltree" ) ||
Expand Down
15 changes: 15 additions & 0 deletions tests/src/python/test_qgsproviderconnection_postgres.py
Expand Up @@ -329,6 +329,21 @@ def test_fields(self):
fields = conn.fields('qgis_test', 'someData')
self.assertEqual(fields.names(), ['pk', 'cnt', 'name', 'name2', 'num_char', 'dt', 'date', 'time', 'geom'])

# Test regression GH #37666
sql = """
DROP TABLE IF EXISTS qgis_test.gh_37666;
CREATE TABLE qgis_test.gh_37666 (id SERIAL PRIMARY KEY);
ALTER TABLE qgis_test.gh_37666 ADD COLUMN geom geometry(POINT,4326);
ALTER TABLE qgis_test.gh_37666 ADD COLUMN geog geography(POINT,4326);
INSERT INTO qgis_test.gh_37666 (id, geom) VALUES (221, ST_GeomFromText('point(9 45)', 4326));
UPDATE qgis_test.gh_37666 SET geog = ST_GeogFromWKB(st_asewkb(geom));
"""

conn.executeSql(sql)
fields = conn.fields('qgis_test', 'gh_37666')
self.assertEqual([f.name() for f in fields], ['id', 'geom', 'geog'])
self.assertEqual([f.typeName() for f in fields], ['int4', 'geometry', 'geography'])

def test_fields_no_pk(self):
"""Test issue: no fields are exposed for raster_columns"""

Expand Down

0 comments on commit ad96c99

Please sign in to comment.