Skip to content

🎧 Your Personal Streaming Service

Mark helper function as unexported

Deluandbde5330bddb
diff --git a/persistence/album_repository.go b/persistence/album_repository.go
index e9c666938..eb7e99591 100644
--- a/persistence/album_repository.go
+++ b/persistence/album_repository.go
@@ -51,7 +51,7 @@ func yearFilter(field string, value interface{}) Sqlizer {
}
func artistFilter(field string, value interface{}) Sqlizer {
- return Exists("media_file", And{
+ return exists("media_file", And{
ConcatExpr("album_id=album.id"),
Or{
Eq{"artist_id": value},
diff --git a/persistence/helpers.go b/persistence/helpers.go
index 7746b36ce..70a611dd7 100644
--- a/persistence/helpers.go
+++ b/persistence/helpers.go
@@ -39,16 +39,16 @@ func toSnakeCase(str string) string {
return strings.ToLower(snake)
}
-func Exists(subTable string, cond squirrel.Sqlizer) exists {
- return exists{subTable: subTable, cond: cond}
+func exists(subTable string, cond squirrel.Sqlizer) existsCond {
+ return existsCond{subTable: subTable, cond: cond}
}
-type exists struct {
+type existsCond struct {
subTable string
cond squirrel.Sqlizer
}
-func (e exists) ToSql() (string, []interface{}, error) {
+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)
return sql, args, err
diff --git a/persistence/helpers_test.go b/persistence/helpers_test.go
index fdc636aeb..dbecce12b 100644
--- a/persistence/helpers_test.go
+++ b/persistence/helpers_test.go
@@ -9,7 +9,7 @@ import (
var _ = Describe("Helpers", func() {
Describe("Exists", func() {
It("constructs the correct EXISTS query", func() {
- e := Exists("album", squirrel.Eq{"id": 1})
+ e := exists("album", squirrel.Eq{"id": 1})
sql, args, err := e.ToSql()
Expect(sql).To(Equal("exists (select 1 from album where id = ?)"))
Expect(args).To(Equal([]interface{}{1}))