Bug report #18784
«Feature has too many attributes» warning with virtual field
|Affected QGIS version:||3.1(master)||Regression?:||Yes|
|Operating System:||Windows 10||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||26671|
The error message «Feature has too many attributes (expecting 1, received 2)» appears when adding elements to a layer with a virtual field. This message should not be displayed in this case, since there is no error. All attributes are correctly saved and the virtual field is correctly updated for all elements.
Steps to reproduce:
1. Create project and create new shapefile vector (type polygon).
2. Draw a few polygons.
3. Open Field Calculator.
4. Create a new virtual field (type number) with the expression "$area".
5. Click OK.
6. Save layer.
7. Add additionnal polygons.
8. Save layer again, an the error message «Feature has too many attributes (expecting 1, received 2)» in the top bar.
#1 Updated by Rob Willson over 2 years ago
This "feature has too many attributes" error message not only pops up on layers with virtual field types for area calculation (memory layers and shapefiles) but also pops up as soon as one makes a join on a field. Although in in most cases the data is saved it is disconcerting to the average user because they think there is a problem with the features they just created. Even more problematic is that pasting into the table with the virtual field will generate hundreds of these errors and so can cause QGIS to hang and so one has to abort and try another way to transfer data between layers. using 3.2.3-Bonn
#4 Updated by emmanuel poizot over 2 years ago
I get also this problem when adding new features in a memory layer (in Python):
1) I create an empty new memory layer
2) I copy a feature from an existing layer
3) I write the cpoied feature to the memory layer
I get then :
"2018-09-24T15:56:27 CRITICAL Couche temporaryLayer : Feature has too many attributes (expecting 0, received 4)"