Bug report #12683

Processing refactor fields: python error on unhandeld field types

Added by Médéric RIBREUX almost 9 years ago. Updated almost 9 years ago.

Assignee:Victor Olaya
Affected QGIS version:2.8.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 #:20790



I am facing errors when I try to use the "refactor fields" algorithm on some Oracle and SQLite layers.

It seems that the data type of some fields are not referenced in the FieldsMappingPanel.py/fieldTypes variable in the FieldsMappingModel class.

So far I've found that SQLite INTEGER (QLongLong for QGIS) and Oracle DATE (QDateTime for QGIS) field types are triggering errors in FieldsMappingPanel.py:

An error has occured while executing Python code:

Traceback (most recent call last):
  File "C:/Users/MRIBREUX/.qgis2/python/plugins\\processing\\algs\\qgis\\ui\\FieldsMappingPanel.py", line 138, in data
    return self.fieldTypes[value]
KeyError: 4

Perhaps should you add some more types in fieldTypes variable. I've tried the following:

    fieldTypes = OrderedDict([
        (QtCore.QVariant.Int, "Integer"),
        (QtCore.QVariant.Double, "Double"),
        (QtCore.QVariant.String, "String"),
        (QtCore.QVariant.DateTime, "Date"),
        (QtCore.QVariant.LongLong, "Double"),
        (QtCore.QVariant.Date, "Date")])

... and was able to use the algorithm. For the moment, I've just found those two missing types but perhaps should we need to add more ?

Cheers !


#1 Updated by Giovanni Manghi almost 9 years ago

  • Priority changed from Severe/Regression to Normal

#2 Updated by Giovanni Manghi almost 9 years ago

  • Pull Request or Patch supplied changed from No to Yes

#3 Updated by Giovanni Manghi almost 9 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

#4 Updated by Giovanni Manghi almost 9 years ago

of course... thanks!

Also available in: Atom PDF