Skip to content
Permalink
Browse files

Add test for #16833

  • Loading branch information
strk committed Jul 19, 2017
1 parent 7395046 commit 462f73cb0e79d79b99c7ade1ea6ebb80f02d54ac
Showing with 18 additions and 0 deletions.
  1. +18 −0 python/plugins/db_manager/db_plugins/postgis/plugin_test.py
@@ -35,6 +35,7 @@

from db_manager.db_plugins.postgis.plugin import PostGisDBPlugin, PGRasterTable
from db_manager.db_plugins.postgis.plugin import PGDatabase
from db_manager.db_plugins.postgis.data_model import PGSqlResultModel
from db_manager.db_plugins.plugin import Table
from db_manager.db_plugins.postgis.connector import PostGisDBConnector

@@ -125,6 +126,23 @@ def check_rasterTableGdalURI(expected_dbname):

check_rasterTableGdalURI(expected_dbname)

# See http://issues.qgis.org/issues/16833
def test_unicodeInQuery(self):
os.environ['PGDATABASE'] = self.testdb
obj = QObject() # needs to be kept alive
database = PGDatabase(obj, QgsDataSourceURI())
self.assertIsInstance(database, PGDatabase)
# SQL as string literal
res = database.sqlResultModel("SELECT 'é'::text", obj)
self.assertIsInstance(res, PGSqlResultModel)
dat = res.getData(0, 0)
self.assertEqual(dat, u"é")
# SQL as unicode literal
res = database.sqlResultModel(u"SELECT 'é'::text", obj)
self.assertIsInstance(res, PGSqlResultModel)
dat = res.getData(0, 0)
self.assertEqual(dat, u"é")


if __name__ == '__main__':
unittest.main()

0 comments on commit 462f73c

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