Initialise UpdatedAt for stash ids (#5680)

* Initialise imported zero time to epoch time

Fixes null time error after importing stash id without updatedAt set

* Update unit tests
This commit is contained in:
WithoutPants
2025-02-26 08:03:35 +11:00
committed by GitHub
parent 1e05766571
commit b8af147a8d
5 changed files with 82 additions and 46 deletions

View File

@@ -309,7 +309,15 @@ func (t *stashIDTable) get(ctx context.Context, id int) ([]models.StashID, error
return ret, nil
}
var epochTime = time.Unix(0, 0).UTC()
func (t *stashIDTable) insertJoin(ctx context.Context, id int, v models.StashID) (sql.Result, error) {
// #5563 - it's possible that zero-value updated at timestamps are provided via import
// replace them with the epoch time
if v.UpdatedAt.IsZero() {
v.UpdatedAt = epochTime
}
var q = dialect.Insert(t.table.table).Cols(t.idColumn.GetCol(), "endpoint", "stash_id", "updated_at").Vals(
goqu.Vals{id, v.Endpoint, v.StashID, v.UpdatedAt},
)