Fix date fields not being nulled correctly when cleared (#3243)

* Interpret empty string date as null
* Fix setSQLiteDate for null
This commit is contained in:
WithoutPants
2022-12-06 13:33:58 +11:00
committed by GitHub
parent c9b0841184
commit 782bed9df8
3 changed files with 7 additions and 6 deletions

View File

@@ -143,7 +143,7 @@ func (t changesetTranslator) optionalDate(value *string, field string) models.Op
return models.OptionalDate{} return models.OptionalDate{}
} }
if value == nil { if value == nil || *value == "" {
return models.OptionalDate{ return models.OptionalDate{
Set: true, Set: true,
Null: true, Null: true,

View File

@@ -102,11 +102,11 @@ func (r *updateRecord) setSQLiteDate(destField string, v models.OptionalDate) {
if v.Set { if v.Set {
if v.Null { if v.Null {
r.set(destField, models.SQLiteDate{}) r.set(destField, models.SQLiteDate{})
} } else {
r.set(destField, models.SQLiteDate{ r.set(destField, models.SQLiteDate{
String: v.Value.String(), String: v.Value.String(),
Valid: true, Valid: true,
}) })
} }
}
} }

View File

@@ -9,6 +9,7 @@
* Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113)) * Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113))
### 🐛 Bug fixes ### 🐛 Bug fixes
* Fixed date fields not being nulled correctly when cleared. ([#3243](https://github.com/stashapp/stash/pull/3243))
* Fixed scene wall items to show file base name where scene has no title set. ([#3242](https://github.com/stashapp/stash/pull/3242)) * Fixed scene wall items to show file base name where scene has no title set. ([#3242](https://github.com/stashapp/stash/pull/3242))
* Fixed image exclusion pattern being applied to all files. ([#3241](https://github.com/stashapp/stash/pull/3241)) * Fixed image exclusion pattern being applied to all files. ([#3241](https://github.com/stashapp/stash/pull/3241))
* Fixed missing captions not being removed during scan. ([#3240](https://github.com/stashapp/stash/pull/3240)) * Fixed missing captions not being removed during scan. ([#3240](https://github.com/stashapp/stash/pull/3240))