Bug report #18784

«Feature has too many attributes» warning with virtual field

Added by Antoine Lafranchis about 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:High
Assignee:Nyall Dawson
Category:Attribute table
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

Description

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.

Associated revisions

Revision a8794001
Added by Nyall Dawson almost 6 years ago

Add method to match feature attributes to the given fields

Refs #18784

Revision cc53af29
Added by Nyall Dawson almost 6 years ago

Fix errors when saving features with virtual fields present

Fixes #18784

History

#1 Updated by Rob Willson almost 6 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

#2 Updated by Giovanni Manghi almost 6 years ago

  • Priority changed from Low to High

If confirmed this would be a severe regression.

#3 Updated by Nyall Dawson almost 6 years ago

  • Assignee set to Nyall Dawson
  • Status changed from Open to In Progress

#4 Updated by emmanuel poizot almost 6 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)"

#5 Updated by Nyall Dawson almost 6 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

#6 Updated by Daan Goedkoop almost 6 years ago

Will this bugfix also be applied to version 3.2.4?

#7 Updated by Nyall Dawson almost 6 years ago

No - there is no 3.2.4 release. 3.2.3 was the final in the 3.2 series.

#8 Updated by Daan Goedkoop almost 6 years ago

Oops, sorry for asking such a stupid question!

#9 Updated by Rob Willson almost 6 years ago

amazing, thank you!

Also available in: Atom PDF