Remove non-album artist_ids from the DB

This commit is contained in:
Deluan
2021-11-05 20:24:41 -04:00
parent 0d9dcebf32
commit 1c82bf5179
5 changed files with 53 additions and 1 deletions
+9 -1
View File
@@ -37,17 +37,25 @@ func toSnakeCase(str string) string {
}
func exists(subTable string, cond squirrel.Sqlizer) existsCond {
return existsCond{subTable: subTable, cond: cond}
return existsCond{subTable: subTable, cond: cond, not: false}
}
func notExists(subTable string, cond squirrel.Sqlizer) existsCond {
return existsCond{subTable: subTable, cond: cond, not: true}
}
type existsCond struct {
subTable string
cond squirrel.Sqlizer
not bool
}
func (e existsCond) ToSql() (string, []interface{}, error) {
sql, args, err := e.cond.ToSql()
sql = fmt.Sprintf("exists (select 1 from %s where %s)", e.subTable, sql)
if e.not {
sql = "not " + sql
}
return sql, args, err
}