Skip to content
Permalink
Browse files

Merge pull request #39154 from elpaso/bugfix-gh37666-no-geometry-in-f…

…ields

Fix DB manager does not show geography in query results
  • Loading branch information
elpaso committed Oct 3, 2020
2 parents 6078fe4 + ad96c99 commit 0580e9eb76a7c11308cae369b62a1c017bb7325f
@@ -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" ) ||
@@ -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"""

0 comments on commit 0580e9e

Please sign in to comment.
You can’t perform that action at this time.