Skip to content

Commit 614db66

Browse files
committed
Added failing test for tables with INHERITS
1 parent 7829497 commit 614db66

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

tests/src/python/test_provider_postgres.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,20 @@ def test_table(dbconn, table_name, wkt):
9393
test_table(self.dbconn, 'mls2d', 'MultiLineString ((0 0, 1 1),(2 2, 3 3))')
9494
test_table(self.dbconn, 'mls3d', 'MultiLineStringZ ((0 0 0, 1 1 1),(2 2 2, 3 3 3))')
9595

96+
def testGetFeaturesUniqueId(self):
97+
def test_unique(dbconn, table_name, num_features):
98+
vl = QgsVectorLayer('%s srid=4326 table="qgis_test".%s (geom) sql=' % (dbconn, table_name), "testgeom", "postgres")
99+
assert(vl.isValid())
100+
features = [f for f in vl.getFeatures()]
101+
featureids = []
102+
for f in features:
103+
self.assertFalse(f.id() in featureids)
104+
featureids.append(f.id())
105+
self.assertEqual(len(features), num_features)
106+
107+
test_unique(self.dbconn, 'someData', 5)
108+
test_unique(self.dbconn, 'base_table', 4)
109+
110+
96111
if __name__ == '__main__':
97112
unittest.main()

tests/testdata/provider/testdata.sql

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,47 @@ CREATE TABLE qgis_test.mls3d(
188188
);
189189

190190
INSERT INTO qgis_test.mls3d values (1, 'srid=4326;MultiLineString((0 0 0, 1 1 1),(2 2 2, 3 3 3))'::geometry);
191+
192+
193+
CREATE TABLE qgis_test.base_table
194+
(
195+
gid serial NOT NULL,
196+
geom geometry(Point,4326),
197+
code character varying,
198+
CONSTRAINT base_pkey PRIMARY KEY (gid)
199+
)
200+
WITH (
201+
OIDS=FALSE
202+
);
203+
204+
CREATE TABLE qgis_test.child_table
205+
(
206+
gid serial NOT NULL,
207+
geom geometry(Point,4326),
208+
code character varying,
209+
CONSTRAINT child_pkey PRIMARY KEY (gid)
210+
)
211+
INHERITS ( qgis_test.base_table)
212+
WITH (
213+
OIDS=FALSE
214+
);
215+
216+
217+
CREATE TABLE qgis_test.child_table2
218+
(
219+
gid serial NOT NULL,
220+
geom geometry(Point,4326),
221+
code character varying,
222+
CONSTRAINT child2_pkey PRIMARY KEY (gid)
223+
)
224+
INHERITS ( qgis_test.base_table)
225+
WITH (
226+
OIDS=FALSE
227+
);
228+
229+
INSERT INTO qgis_test.child_table (gid, geom, code) VALUES (1, 'srid=4326;Point(0 0)'::geometry, 'child 1');
230+
INSERT INTO qgis_test.child_table (gid, geom, code) VALUES (2, 'srid=4326;Point(1 1)'::geometry, 'child 2');
231+
232+
233+
INSERT INTO qgis_test.child_table2 (gid, geom, code) VALUES (1, 'srid=4326;Point(-1 -1)::geometry', 'child2 1');
234+
INSERT INTO qgis_test.child_table2 (gid, geom, code) VALUES (2, 'srid=4326;Point(-1 1)::geometry', 'child2 2');

0 commit comments

Comments
 (0)