Bug report #17790
NULL constraint not respected on date time edit with todays date
|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|
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
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.
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).