Skip to content

Commit 13ccf70

Browse files
committedJan 20, 2016
test vector join: add PostgreSQL provider
1 parent c288311 commit 13ccf70

File tree

8 files changed

+279
-108
lines changed

8 files changed

+279
-108
lines changed
 

‎ci/travis/linux/before_script.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
printf "[qgis_test]\nhost=localhost\ndbname=qgis_test\nuser=postgres" > ~/.pg_service.conf
22
psql -c 'CREATE DATABASE qgis_test;' -U postgres
3-
psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata.sql -U postgres -d qgis_test
4-
psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/reltests.sql -U postgres -d qgis_test
3+
psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata_pg.sql -U postgres -d qgis_test
4+
psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata_pg_reltests.sql -U postgres -d qgis_test
5+
psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata_pg_vectorjoin.sql -U postgres -d qgis_test

‎src/core/qgsvectorlayerjoinbuffer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ bool QgsVectorLayerJoinBuffer::addJoin( const QgsVectorJoinInfo& joinInfo )
8585
// but then QgsProject makes sure to call createJoinCaches() which will do the connection.
8686
// Unique connection makes sure we do not respond to one layer's update more times (in case of multiple join)
8787
if ( QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( joinInfo.joinLayerId ) ) )
88+
{
8889
connect( vl, SIGNAL( updatedFields() ), this, SLOT( joinedLayerUpdatedFields() ), Qt::UniqueConnection );
90+
}
8991

9092
emit joinedFieldsChanged();
9193
return true;

‎tests/src/core/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ INCLUDE_DIRECTORIES(SYSTEM
3333
ADD_DEFINITIONS(-DTEST_DATA_DIR="\\"${TEST_DATA_DIR}\\"")
3434

3535
ADD_DEFINITIONS(-DINSTALL_PREFIX="\\"${CMAKE_INSTALL_PREFIX}\\"")
36+
37+
# enable postgresql tests
38+
SET (ENABLE_PGTEST FALSE CACHE BOOL "Enable PostgreSQL provider tests")
39+
IF ( ENABLE_PGTEST )
40+
ADD_DEFINITIONS( "-DENABLE_PGTEST" )
41+
ENDIF ()
42+
3643
#############################################################
3744
# libraries
3845

‎tests/src/core/testqgsvectorlayerjoinbuffer.cpp

Lines changed: 227 additions & 102 deletions
Large diffs are not rendered by default.

‎tests/src/python/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
SET (ENABLE_PGTEST FALSE CACHE BOOL "Enable PostgreSQL provider tests")
21
SET (ENABLE_MSSQLTEST FALSE CACHE BOOL "Enable MsSQL provider tests")
32

43
INCLUDE(UsePythonTest)

‎tests/testdata/provider/reltests.sql renamed to ‎tests/testdata/provider/testdata_pg_reltests.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-- Table: qgis_test.authors
22

3-
-- DROP TABLE qgis_test.authors;
3+
DROP TABLE IF EXISTS qgis_test.books_authors;
4+
DROP TABLE IF EXISTS qgis_test.authors;
5+
DROP TABLE IF EXISTS qgis_test.books;
46

57
CREATE TABLE qgis_test.authors
68
(
@@ -12,7 +14,6 @@ CREATE TABLE qgis_test.authors
1214

1315
-- Table: qgis_test.books
1416

15-
-- DROP TABLE qgis_test.books;
1617

1718
CREATE TABLE qgis_test.books
1819
(
@@ -24,7 +25,6 @@ CREATE TABLE qgis_test.books
2425

2526
-- Table: qgis_test.books_authors
2627

27-
-- DROP TABLE qgis_test.books_authors;
2828

2929
CREATE TABLE qgis_test.books_authors
3030
(
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
CREATE SCHEMA IF NOT EXISTS qgis_test;
3+
4+
5+
DROP TABLE IF EXISTS qgis_test.table_a;
6+
DROP TABLE IF EXISTS qgis_test.table_b;
7+
DROP TABLE IF EXISTS qgis_test.table_c;
8+
DROP TABLE IF EXISTS qgis_test.table_x;
9+
10+
CREATE TABLE qgis_test.table_a
11+
(
12+
id_a integer NOT NULL,
13+
CONSTRAINT table_a_pkey PRIMARY KEY (id_a)
14+
);
15+
16+
CREATE TABLE qgis_test.table_b
17+
(
18+
id_b integer NOT NULL,
19+
value_b integer,
20+
CONSTRAINT table_b_pkey PRIMARY KEY (id_b)
21+
);
22+
23+
CREATE TABLE qgis_test.table_c
24+
(
25+
id_c integer NOT NULL,
26+
value_c integer,
27+
CONSTRAINT table_c_pkey PRIMARY KEY (id_c)
28+
);
29+
30+
CREATE TABLE qgis_test.table_x
31+
(
32+
id_x integer NOT NULL,
33+
value_x1 integer,
34+
value_x2 integer,
35+
CONSTRAINT table_x_pkey PRIMARY KEY (id_x)
36+
);
37+

0 commit comments

Comments
 (0)
Please sign in to comment.