mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
SQLite model refactoring, part 2 (#3839)
* Treat empty image input as null * Add validation to models.Date * Allow zero dates in database * Make scene_markers.scene_id non-nullable * Drop scraped_items table * Remove movie/studio checksum * Add migration notes --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -97,7 +97,7 @@ func Test_sceneQueryBuilder_Create(t *testing.T) {
|
||||
stashID1 = "stashid1"
|
||||
stashID2 = "stashid2"
|
||||
|
||||
date = models.NewDate("2003-02-01")
|
||||
date, _ = models.ParseDate("2003-02-01")
|
||||
|
||||
videoFile = makeFileWithID(fileIdxStartVideoFiles)
|
||||
)
|
||||
@@ -336,7 +336,7 @@ func Test_sceneQueryBuilder_Update(t *testing.T) {
|
||||
stashID1 = "stashid1"
|
||||
stashID2 = "stashid2"
|
||||
|
||||
date = models.NewDate("2003-02-01")
|
||||
date, _ = models.ParseDate("2003-02-01")
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@@ -552,7 +552,7 @@ func Test_sceneQueryBuilder_UpdatePartial(t *testing.T) {
|
||||
stashID1 = "stashid1"
|
||||
stashID2 = "stashid2"
|
||||
|
||||
date = models.NewDate("2003-02-01")
|
||||
date, _ = models.ParseDate("2003-02-01")
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
@@ -1460,10 +1460,6 @@ func makeSceneWithID(index int) *models.Scene {
|
||||
ret := makeScene(index)
|
||||
ret.ID = sceneIDs[index]
|
||||
|
||||
if ret.Date != nil && ret.Date.IsZero() {
|
||||
ret.Date = nil
|
||||
}
|
||||
|
||||
ret.Files = models.NewRelatedVideoFiles([]*file.VideoFile{makeSceneFile(index)})
|
||||
|
||||
return ret
|
||||
@@ -3243,12 +3239,12 @@ func TestSceneQueryIsMissingDate(t *testing.T) {
|
||||
|
||||
scenes := queryScene(ctx, t, sqb, &sceneFilter, nil)
|
||||
|
||||
// three in four scenes have no date
|
||||
assert.Len(t, scenes, int(math.Ceil(float64(totalScenes)/4*3)))
|
||||
// one in four scenes have no date
|
||||
assert.Len(t, scenes, int(math.Ceil(float64(totalScenes)/4)))
|
||||
|
||||
// ensure date is null, empty or "0001-01-01"
|
||||
// ensure date is null
|
||||
for _, scene := range scenes {
|
||||
assert.True(t, scene.Date == nil || scene.Date.Time == time.Time{})
|
||||
assert.Nil(t, scene.Date)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -3293,7 +3289,7 @@ func TestSceneQueryIsMissingRating(t *testing.T) {
|
||||
|
||||
assert.True(t, len(scenes) > 0)
|
||||
|
||||
// ensure date is null, empty or "0001-01-01"
|
||||
// ensure rating is null
|
||||
for _, scene := range scenes {
|
||||
assert.Nil(t, scene.Rating)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user