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

@@ -294,11 +294,20 @@ func (r *repository) join(j joiner, as string, parentIDCol string) {
if as != "" {
t = as
}
j.addJoin(r.tableName, as, fmt.Sprintf("%s.%s = %s", t, r.idColumn, parentIDCol))
j.addLeftJoin(r.tableName, as, fmt.Sprintf("%s.%s = %s", t, r.idColumn, parentIDCol))
}
func (r *repository) innerJoin(j joiner, as string, parentIDCol string) {
t := r.tableName
if as != "" {
t = as
}
j.addInnerJoin(r.tableName, as, fmt.Sprintf("%s.%s = %s", t, r.idColumn, parentIDCol))
}
type joiner interface {
addJoin(table, as, onClause string)
addLeftJoin(table, as, onClause string)
addInnerJoin(table, as, onClause string)
}
type joinRepository struct {