-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6310 from 3nids/pd_domain_218
[postgres] fix domain not in public schema
- Loading branch information
Showing
5 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for Postgres domains. | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
__author__ = 'Denis Rouzaud' | ||
__date__ = '10/02/2018' | ||
__copyright__ = 'Copyright 2018, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
import qgis # NOQA | ||
|
||
import os | ||
|
||
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry | ||
|
||
from qgis.testing import start_app, unittest | ||
|
||
start_app() | ||
|
||
|
||
class TestQgsPostgresDomain(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
""" | ||
Setup the involved layer | ||
:return: | ||
""" | ||
cls.dbconn = 'service=\'qgis_test\'' | ||
if 'QGIS_PGTEST_DB' in os.environ: | ||
cls.dbconn = os.environ['QGIS_PGTEST_DB'] | ||
# Create test layer | ||
cls.vl = QgsVectorLayer(cls.dbconn + ' sslmode=disable key=\'pk\' table="qgis_test"."colors" sql=', 'colors', 'postgres') | ||
|
||
QgsMapLayerRegistry.instance().addMapLayer(cls.vl, True) | ||
|
||
def test_postgres_domain(self): | ||
self.assertEqual(self.vl.dataProvider().enumValues(1), ['red', 'green', 'blue']) | ||
self.assertEqual(self.vl.dataProvider().enumValues(2), ['yellow', 'cyan', 'magenta']) | ||
self.assertEqual(self.vl.dataProvider().enumValues(3), ['Alchemilla', 'Alstroemeria', 'Alyssum']) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
|
||
|
||
CREATE DOMAIN public.colordomain | ||
AS text | ||
COLLATE pg_catalog."default" | ||
CONSTRAINT domainconstraint CHECK (VALUE = ANY (ARRAY['red'::text, 'green'::text, 'blue'::text])); | ||
|
||
CREATE DOMAIN qgis_test.colordomain | ||
AS text | ||
COLLATE pg_catalog."default" | ||
CONSTRAINT domainconstraint CHECK (VALUE = ANY (ARRAY['yellow'::text, 'cyan'::text, 'magenta'::text])); | ||
|
||
CREATE DOMAIN qgis_test.flowerdomain | ||
AS text | ||
COLLATE pg_catalog."default" | ||
CONSTRAINT domainconstraint CHECK (VALUE = ANY (ARRAY['Alchemilla'::text, 'Alstroemeria'::text, 'Alyssum'::text])); | ||
|
||
CREATE TABLE qgis_test.colors | ||
( | ||
id SERIAL NOT NULL, | ||
color_public colordomain, | ||
color_qgis qgis_test.colordomain, | ||
flower qgis_test.flowerdomain | ||
) |