Skip to content

Commit

Permalink
Add test for extracting candidate primary keys from geometryless view
Browse files Browse the repository at this point in the history
  • Loading branch information
strk committed Nov 9, 2019
1 parent 4b8d3e7 commit cf15a6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/src/python/test_qgsproviderconnection_postgres.py
Expand Up @@ -111,6 +111,14 @@ def test_postgis_connections(self):
self.assertFalse('geometries_table' in table_names)
self.assertFalse('geometries_view' in table_names)

tables = conn.tables('qgis_test', QgsAbstractDatabaseProviderConnection.Aspatial | QgsAbstractDatabaseProviderConnection.View)
table_names = self._table_names(tables)
b32523_view = self._table_by_name(tables, 'b32523')
self.assertTrue(b32523_view)
pks = b32523_view.primaryKeyColumns()
self.assertTrue('pk' in pks)
self.assertTrue('random' in pks)

geometries_table = self._table_by_name(conn.tables('qgis_test'), 'geometries_table')
srids_and_types = [[t.crs.postgisSrid(), t.wkbType]
for t in geometries_table.geometryColumnTypes()]
Expand Down
11 changes: 10 additions & 1 deletion tests/testdata/provider/testdata_pg.sql
Expand Up @@ -661,4 +661,13 @@ CREATE VIEW qgis_test.some_poly_data_shift_bbox AS
--

CREATE TABLE qgis_test.b31799_test_table AS (SELECT (ST_DumpPoints(ST_GeneratePoints(ST_Expand('SRID=4326;POINT(0 0)'::geometry,90),10))).geom, random());
CREATE VIEW qgis_test.b31799_test_view_ctid AS (SELECT ctid, geom, random() FROM qgis_test.b31799_test_table, pg_sleep(0.1));
CREATE VIEW qgis_test.b31799_test_view_ctid AS (SELECT ctid, geom, random() FROM qgis_test.b31799_test_table, pg_sleep(0.1));

---------------------------------------------
--
-- Geometryless view
-- See https://github.com/qgis/QGIS/issues/32523
--
CREATE VIEW qgis_test.b32523 AS
SELECT pk, random()
FROM qgis_test.some_poly_data;

0 comments on commit cf15a6f

Please sign in to comment.