qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.29k stars 2.96k forks source link

Processing refactor fields: python error on unhandeld field types #20790

Closed qgib closed 5 years ago

qgib commented 9 years ago

Author Name: Médéric RIBREUX (Médéric RIBREUX) Original Redmine Issue: 12683 Affected QGIS version: 2.8.1 Redmine category:processing/qgis Assignee: Victor Olaya


Hello,

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 !

qgib commented 9 years ago

Author Name: Giovanni Manghi (@gioman)


qgib commented 9 years ago

Author Name: Giovanni Manghi (@gioman)


see

https://github.com/qgis/QGIS/pull/2033


qgib commented 9 years ago

Author Name: Giovanni Manghi (@gioman)


qgib commented 9 years ago

Author Name: Giovanni Manghi (@gioman)


of course... thanks!