Skip to content
Permalink
Browse files

Fix postgres unit test

  • Loading branch information
m-kuhn committed Apr 7, 2016
1 parent e98e16f commit eecd77a324018969a0fbaf66daf38cd11c35a3e0
Showing with 16 additions and 10 deletions.
  1. +4 −4 tests/src/python/test_provider_postgres.py
  2. +12 −6 tests/testdata/provider/testdata_pg.sql
@@ -166,14 +166,14 @@ def test_query_attribute(dbconn, query, att, val, fidval):
test_query_attribute(self.dbconn, '(SELECT -65535::int8 i, NULL::geometry(Point) g)', 'i', -65535, 1)

def testPktMapInsert(self):
vl = QgsVectorLayer('{} table="qgis_test"."{}" key="pk" sql='.format(self.dbconn, 'books_view'), "books_view", "postgres")
vl = QgsVectorLayer('{} table="qgis_test"."{}" key="pk" sql='.format(self.dbconn, 'bikes_view'), "bikes_view", "postgres")
self.assertTrue(vl.isValid())
f = QgsFeature(vl.fields())
f.setAttribute(0, NULL)
f.setAttribute(1, 'Das Drama des begabten Kindes')
f['pk'] = NULL
f['name'] = 'Cilo'
r, f = vl.dataProvider().addFeatures([f])
self.assertTrue(r)
self.assertIsNotNone(f[0]['pk'])
self.assertNotEqual(f[0]['pk'], NULL)
vl.deleteFeatures([f[0].id()])

if __name__ == '__main__':
@@ -312,7 +312,14 @@ INSERT INTO qgis_test.child_table2_good (geom, code2) VALUES ('srid=4326;Point(-
--------------------------------------
-- A writable view
--
CREATE OR REPLACE VIEW qgis_test.books_view

CREATE TABLE qgis_test.bikes
(
pk serial NOT NULL,
name character varying(255)
);

CREATE OR REPLACE VIEW qgis_test.bikes_view
AS
SELECT *
FROM qgis_test.books;
@@ -321,7 +328,7 @@ CREATE OR REPLACE FUNCTION qgis_test.books_view_insert()
RETURNS trigger AS
$BODY$
BEGIN
INSERT INTO qgis_test.books (
INSERT INTO qgis_test.bikes (
"name"
)
VALUES (
@@ -331,8 +338,7 @@ BEGIN

RETURN NEW;
END; $BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
LANGUAGE plpgsql VOLATILE;

CREATE TRIGGER books_view_ON_INSERT INSTEAD OF INSERT ON qgis_test.books_view
FOR EACH ROW EXECUTE PROCEDURE qgis_test.books_view_insert();
CREATE TRIGGER bikes_view_ON_INSERT INSTEAD OF INSERT ON qgis_test.bikes_view
FOR EACH ROW EXECUTE PROCEDURE qgis_test.bikes_view_insert();

0 comments on commit eecd77a

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