Skip to content

Commit

Permalink
Mark helper function as unexported
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed May 1, 2020
1 parent 9b817ed commit dbde533
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion persistence/album_repository.go
Expand Up @@ -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},
Expand Down
8 changes: 4 additions & 4 deletions persistence/helpers.go
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion persistence/helpers_test.go
Expand Up @@ -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}))
Expand Down

0 comments on commit dbde533

Please sign in to comment.