Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all geometry types are found in PostGIS table with Spatial Type of Geometry #43186

Closed
rgreenwood opened this issue May 11, 2021 · 2 comments · Fixed by #43419
Closed

Not all geometry types are found in PostGIS table with Spatial Type of Geometry #43186

rgreenwood opened this issue May 11, 2021 · 2 comments · Fixed by #43419
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PostGIS data provider

Comments

@rgreenwood
Copy link

Describe the bug
When connecting to a PostGIS table with Spatial Type of "Geometry" not all of the geometry types in the table were detected.

How to Reproduce
Attached is a PostgeSQL backup file multiple_gometries.backup.zip containing a single table with approx 11,000 rows, the "first" ~7,000 of which are LineStrings and the "last" is a Polygon and the rest are Points. I put "first" and "last" in quotes because I'm not explicitly ordering the data, it was put into the table in that sequence and might not remain so after vacuuming. When connecting to this table only one entry appears in the in the Connections list and that is of type LineString. There should be three entries of type Point, LineString, and Polygon. So it seems that QGIS is not looking at all rows to find all geometry types.

QGIS and OS versions
3.18.2 on Ubuntu 20.04

@rgreenwood rgreenwood added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 11, 2021
@gioman
Copy link
Contributor

gioman commented May 12, 2021

SELECT DISTINCT ST_GeometryType(wkb_geometry)
FROM work.tracts;

"ST_LineString"
"ST_Polygon"
"ST_Point"
SELECT ogc_fid, ST_GeometryType(wkb_geometry)
FROM work.tracts
WHERE ST_GeometryType(wkb_geometry)='ST_Polygon';

7855 "ST_Polygon"

The polygon feature can be added with DB Manager ("Add layer advanced") and they show in the canvas, but the QGIS log registers:

2021-05-12T17:37:57 WARNING Feature type or srid for wkb_geometry of "work"."tracts" could not be determined or was not requested.

On master/ubuntu I can see both the point and line features in the browser and the "add postgis layer" dialog.

@elpaso
Copy link
Contributor

elpaso commented May 27, 2021

@rgreenwood there is an hardcoded limit in the QGIS implementation that prevents a full table scan. I'll check if it can be removed without risks.

elpaso added a commit to elpaso/QGIS that referenced this issue May 27, 2021
Remove the LIMIT when not using estimated metadata.

Fixes qgis#43186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PostGIS data provider
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants