Bug report #8920

DB Manager Fails to Load Raster | QGIS 2.0.1

Added by Matthew Kenny about 11 years ago. Updated almost 11 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:DB Manager
Affected QGIS version:2.0.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:17594

Description

Hello, I'm receiving the following error below when trying to load a raster stored in PostGIS, via the QGIS db manager plugin. I'm currently using a QGIS on a Mac, with the following build notes:

QGIS version 2.0.1-Dufour QGIS code revision f738351
Compiled against Qt 4.8.5 Running against Qt 4.8.5
Compiled against GDAL/OGR 1.10.1 Running against GDAL/OGR 1.10.1
Compiled against GEOS 3.4.2-CAPI-1.8.2 Running against GEOS 3.4.2-CAPI-1.8.2 r3921
PostgreSQL Client Version 9.2.4 SpatiaLite Version 4.1.1
QWT Version 6.0.2 PROJ.4 Version 480
QScintilla2 Version 2.7.2

An error has occured while executing Python code:

Traceback (most recent call last):
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_manager.py", line 83, in itemChanged
    self.refreshTabs()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_manager.py", line 134, in refreshTabs
    self.info.showInfo( item )
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/info_viewer.py", line 75, in showInfo
    self._showTableInfo(item)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/info_viewer.py", line 132, in _showTableInfo
    html += table.info().toHtml()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/info_model.py", line 352, in toHtml
    ret = self.getTableInfo()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/postgis/info_model.py", line 194, in getTableInfo
    ret = TableInfo.getTableInfo(self)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/info_model.py", line 285, in getTableInfo
    general_info = self.generalInfo()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/postgis/info_model.py", line 95, in generalInfo
    if len( filter(lambda fld: fld.primaryKey, self.table.fields()) )   File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/plugin.py", line 613, in fields
    self._fields = map(lambda x: self.tableFieldsFactory(x, self), fields)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/plugin.py", line 613, in 
    self._fields = map(lambda x: self.tableFieldsFactory(x, self), fields)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 229, in tableFieldsFactory
    return PGTableField(row, table)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 311, in __init__
    for con in self.table().constraints():
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/plugin.py", line 660, in constraints
    self._constraints = map(lambda x: self.tableConstraintsFactory(x, self), constraints)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/plugin.py", line 660, in 
    self._constraints = map(lambda x: self.tableConstraintsFactory(x, self), constraints)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 232, in tableConstraintsFactory
    return PGTableConstraint(row, table)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 334, in __init__
    self.foreignMatchType = TableConstraint.matchTypes[row[9]]
KeyError: u's'

Python version:
2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

QGIS version:
2.0.1-Dufour Dufour, f738351

Python path: ['/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', '/Users/matt/.qgis2/python', '/Users/matt/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/B/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7', '/Library/Frameworks/GDAL.framework/Versions/1.10/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/swampy-2.1.1-py2.7.egg', '/Library/Python/2.7/site-packages/pygooglechart-0.3.0-py2.7.egg', '/Library/Python/2.7/site-packages/GChartWrapper-0.9-py2.7.egg', '/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools']

History

#1 Updated by Giovanni Manghi about 11 years ago

  • Category set to DB Manager

#2 Updated by Max Bohnet about 11 years ago

The error occures not only with raster tables but with all tables, that have a foreign key constraint with a "MATCH SIMPLE" match type.
I added 's': 'SIMPLE' to the matchTypes-Dictionary of the TableConstraint class in line 988 in db_plugins\\plugins.py. So it works fine for me:
matchTypes = { "u" : "UNSPECIFIED", "f" : "FULL", "p" : "PARTIAL" , "s": 'SIMPLE',}

How can i submit that patch?

#3 Updated by C Daniel Sanchez R. almost 11 years ago

This bug is present in 2.1.0-Master (Debian Jessie amd64, Nightly build), and postgreSQL 9.3
Patch suggested by Max corrects this error. Please apply it as soon as possible.

Thanks.

#4 Updated by Giovanni Manghi almost 11 years ago

  • Target version set to Future Release - High Priority
  • Pull Request or Patch supplied changed from No to Yes
  • Status changed from Open to Feedback

Max Bohnet wrote:

The error occures not only with raster tables but with all tables, that have a foreign key constraint with a "MATCH SIMPLE" match type.
I added 's': 'SIMPLE' to the matchTypes-Dictionary of the TableConstraint class in line 988 in db_plugins\\plugins.py. So it works fine for me:
matchTypes = { "u" : "UNSPECIFIED", "f" : "FULL", "p" : "PARTIAL" , "s": 'SIMPLE',}

How can i submit that patch?

Please submit the patch as pull request in the qgis github repository

https://github.com/qgis/QGIS/commits/master

#5 Updated by Tim Sutton almost 11 years ago

I merged your pull request here https://github.com/qgis/QGIS/pull/1042 - many thanks!

#6 Updated by Tim Sutton almost 11 years ago

  • Resolution set to fixed/implemented

#7 Updated by Matthias Kuhn almost 11 years ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF