Using QgsDataSourceURI to load a PostGIS table causes error if query returns empty and Geometry type is GEOMETRY #15431
Labels
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
Data Provider
Related to specific vector, raster or mesh data providers
Author Name: Ian Packham (Ian Packham)
Original Redmine Issue: 6074
Affected QGIS version: master
Redmine category:data_provider/postgis
I am using the following code to load a vector layer from a PostGIS table:
If the @sqlstmt@ returns an empty query, in some cases my plugin shows the "Layer failed to load!" message meaning the layer is invalid (but is never caught by the previous @Try@ block).
Error in the General Log Messages is:
On investigation I have discovered that if the Geometry type of the PostGIS layer is the generic GEOMETRY type, then I get this error. If the Geometry type is MultiPolygon or MultiPoint, then an empty layer works OK.
If this is expected behaviour then should we avoid the GEOMETRY type in our PostGIS tables?
The text was updated successfully, but these errors were encountered: