Bug report #21304

"default value" is not applied when pasting features

Added by Giovanni Manghi over 5 years ago. Updated over 5 years ago.

Status:Closed
Priority:High
Assignee:Alessandro Pasotti
Category:Edit widget
Affected QGIS version:3.5(master) Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29122

Description

In QGIS master the "default value" for a field is not applied when pasting a new feature.

It works ok (as usual) for new digitized features.

Does not affects 3.4.4

Steps:

1) set a default value for a field of a vector

2) digitize a new feature, do not fill the column where the default was set > default is applied

3) copy a feature from another layer and paste it in the layer with the default (the source layer must not have a filled field that can possibly fill the equivalent field in the target layer) > default is not applied

Recording #3.mp4 (3.97 MB) Giovanni Manghi, 2019-02-19 10:48 PM

test1.zip (1.59 MB) Giovanni Manghi, 2019-02-19 10:51 PM

Associated revisions

Revision bf1575f4
Added by Alessandro Pasotti over 5 years ago

Also check for nulls when applying defaults

isValid is not enough because fields are initialized with
QVariant(field.type()) which is valid but null.

Fixes #21304

With test

History

#1 Updated by Alessandro Pasotti over 5 years ago

  • Assignee set to Alessandro Pasotti

#2 Updated by Alessandro Pasotti over 5 years ago

  • Status changed from Open to Feedback

I cannot reproduce, can you attach a sample project and data?

#3 Updated by Giovanni Manghi over 5 years ago

Screencast and project attached (datasources are gpkg, but is the same for different ones).

#4 Updated by Alessandro Pasotti over 5 years ago

  • Status changed from Feedback to In Progress

#5 Updated by Alessandro Pasotti over 5 years ago

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

Also available in: Atom PDF