Bug report #17790

NULL constraint not respected on date time edit with todays date

Added by Matthias Kuhn over 2 years ago. Updated over 2 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Edit widget
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:25686

Description

1. Create a date time edit widget for a field
2. Set a NOT NULL constraint
3. Create a new feature
4. Change the date from NULL to the current date

Expected: Constraint check is ok
Observed:

Constraint check still reports a constraint problem
To work around this, another date than the current one has to be set first

Tested with a postgres table with a "date" field and a server side NOT NULL constraint.

Associated revisions

Revision d8cc285f
Added by Denis Rouzaud over 2 years ago

fix NULL constraint on date/time widget with allow NULL

the issue was that widget wrapper was using parent QDateTimeEdit::dateTimeChanged signal. It was connected both internally to QgsDateTimeEdit::changed and in the form to detect changes. When QgsAttributeForm was recreating the updated feature it was calling QgsDateTimeEdit::value() before changed() could update the value (i.e. setting mIsNull to false).

fix #17790

History

#1 Updated by Matthias Kuhn over 2 years ago

Actually it's not about the today date. It's always when switching from NULL to any other date, the constraint is not updated immediately.

#2 Updated by Denis Rouzaud over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

#3 Updated by Giovanni Manghi over 2 years ago

  • Resolution set to fixed/implemented

Also available in: Atom PDF