Bug report #12257
Cannot create virtual field with delimited text layer
|Affected QGIS version:||2.8.0||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||20442|
When trying to add a field to a delimited text layer the Field Calculator UI does not enable the Output field type, width, and precision fields. This makes it impossible to define a valid field. So when OK is clicked, it is blocked with a message "Could not add the new field to the provider".
Steps to reproduce:
- Open a valid CSV file in QGIS
- open the attribute table on the new layer
- open the field calculator dialog
- enter output field name "answer"
- enter expression "42"
- click OK.
Notes 1: It is possible to add a virtual field via python, ie
from PyQt4.QtCore import *
Notes 2: The UI should not enable the OK button if a valid field type is not selected
#1 Updated by Chris Crook over 6 years ago
Note: The issue comes from the logic used to identify when the calculator should create a virtual field. In this case despite the fact that the virtual field check box is checked (and not enabled), there is a second condition, on the new field checkbox, which is not met. Instead the calculator tries to create a provider field and fails.
The issue with no field data type being selectable is separate and relates to the delimited text provider. This is addressed in pull request #1931, which I have merged into master. If the other issue with the field calculator gets fixed I'd appreciate if it and #1931 could be backported to 2.8.1.