Skip to content

Commit dd78876

Browse files
author
Sandro Santilli
committed
Allow loading pgraster tables with non-default raster field name
Before this change you could only load tables where the raster field was named "rast".
1 parent e91141c commit dd78876

File tree

1 file changed

+11
-2
lines changed
  • python/plugins/db_manager/db_plugins/postgis

1 file changed

+11
-2
lines changed

python/plugins/db_manager/db_plugins/postgis/plugin.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,17 @@ def gdalUri(self):
283283
user = ( u'user=%s' % uri.username() ) if uri.username() else ''
284284
passw = ( u'password=%s' % uri.password() ) if uri.password() else ''
285285
port = ( u'port=%s' % uri.port() ) if uri.port() else ''
286-
gdalUri = u'PG: %s %s %s %s %s mode=2 %s table=%s' % \
287-
(dbname, host, user, passw, port, schema, self.name)
286+
287+
# Find first raster field
288+
col = ''
289+
for fld in self.fields():
290+
if fld.dataType == "raster":
291+
col = u'column=%s' % fld.name
292+
break
293+
294+
gdalUri = u'PG: %s %s %s %s %s mode=2 %s %s table=%s' % \
295+
(dbname, host, user, passw, port, schema, col, self.name)
296+
288297
return gdalUri
289298

290299
def mimeUri(self):

0 commit comments

Comments
 (0)