Skip to content

Commit

Permalink
dbmanager/postgis: quote identifiers in urls (fixes qgis portion of #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Aug 10, 2018
1 parent c7421c7 commit f4d08eb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/plugins/db_manager/db_plugins/postgis/plugin.py
Expand Up @@ -316,9 +316,9 @@ def info(self):
def gdalUri(self, uri=None):
if not uri:
uri = self.database().uri()
service = (u'service=%s' % uri.service()) if uri.service() else ''
schema = (u'schema=%s' % self.schemaName()) if self.schemaName() else ''
dbname = (u'dbname=%s' % uri.database()) if uri.database() else ''
service = (u'service=\'%s\'' % uri.service()) if uri.service() else ''
schema = (u'schema=\'%s\'' % self.schemaName()) if self.schemaName() else ''
dbname = (u'dbname=\'%s\'' % uri.database()) if uri.database() else ''
host = (u'host=%s' % uri.host()) if uri.host() else ''
user = (u'user=%s' % uri.username()) if uri.username() else ''
passw = (u'password=%s' % uri.password()) if uri.password() else ''
Expand All @@ -330,17 +330,17 @@ def gdalUri(self, uri=None):
# TODO: cache this ?
connector = self.database().connector
r = connector._execute(None, "SELECT current_database()")
dbname = (u'dbname=%s' % connector._fetchone(r)[0])
dbname = (u'dbname=\'%s\'' % connector._fetchone(r)[0])
connector._close_cursor(r)

# Find first raster field
col = ''
for fld in self.fields():
if fld.dataType == "raster":
col = u'column=%s' % fld.name
col = u'column=\'%s\'' % fld.name
break

gdalUri = u'PG: %s %s %s %s %s %s mode=2 %s %s table=%s' % \
gdalUri = u'PG: %s %s %s %s %s %s mode=2 %s %s table=\'%s\'' % \
(service, dbname, host, user, passw, port, schema, col, self.name)

return gdalUri
Expand Down

0 comments on commit f4d08eb

Please sign in to comment.