Use inner join when getting images in a gallery (#2083)

* Added joinType to join struct
* Added addInnerJoin function to perform INNER JOIN type of joins
* Added innerJoin function to perform INNER JOIN type of joins
* Use inner joins when querying images in a gallery
* Renamed addJoin to addLeftJoin
This commit is contained in:
Esteban Sanchez
2021-12-06 02:30:40 +01:00
committed by GitHub
parent 2460664dc3
commit 70d9a05580
13 changed files with 129 additions and 71 deletions

View File

@@ -69,6 +69,32 @@ func TestImageFindByPath(t *testing.T) {
})
}
func TestImageFindByGalleryID(t *testing.T) {
withTxn(func(r models.Repository) error {
sqb := r.Image()
images, err := sqb.FindByGalleryID(galleryIDs[galleryIdxWithTwoImages])
if err != nil {
t.Errorf("Error finding images: %s", err.Error())
}
assert.Len(t, images, 2)
assert.Equal(t, imageIDs[imageIdx1WithGallery], images[0].ID)
assert.Equal(t, imageIDs[imageIdx2WithGallery], images[1].ID)
images, err = sqb.FindByGalleryID(galleryIDs[galleryIdxWithScene])
if err != nil {
t.Errorf("Error finding images: %s", err.Error())
}
assert.Len(t, images, 0)
return nil
})
}
func TestImageQueryQ(t *testing.T) {
withTxn(func(r models.Repository) error {
const imageIdx = 2