Merge pull request #1702 from strk/pgsql-fix

Fix PostgreSQL error on empty repository list
This commit is contained in:
Brad Rydzewski 2016-07-06 10:39:57 -07:00 committed by GitHub
commit 59b0200412
2 changed files with 12 additions and 3 deletions

View file

@ -24,6 +24,7 @@ func (db *datastore) GetRepoListOf(listof []*model.RepoLite) ([]*model.Repo, err
repos []*model.Repo
args []interface{}
stmt string
err error
)
switch meddler.Default {
case meddler.PostgreSQL:
@ -31,7 +32,9 @@ func (db *datastore) GetRepoListOf(listof []*model.RepoLite) ([]*model.Repo, err
default:
stmt, args = toList(listof)
}
err := meddler.QueryAll(db, &repos, fmt.Sprintf(repoListOfQuery, stmt), args...)
if len(args) > 0 {
err = meddler.QueryAll(db, &repos, fmt.Sprintf(repoListOfQuery, stmt), args...)
}
return repos, err
}

View file

@ -30,6 +30,7 @@ func (db *datastore) GetUserFeed(listof []*model.RepoLite) ([]*model.Feed, error
feed []*model.Feed
args []interface{}
stmt string
err error
)
switch meddler.Default {
case meddler.PostgreSQL:
@ -37,7 +38,9 @@ func (db *datastore) GetUserFeed(listof []*model.RepoLite) ([]*model.Feed, error
default:
stmt, args = toList(listof)
}
err := meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedQuery, stmt), args...)
if len(args) > 0 {
err = meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedQuery, stmt), args...)
}
return feed, err
}
@ -46,6 +49,7 @@ func (db *datastore) GetUserFeedLatest(listof []*model.RepoLite) ([]*model.Feed,
feed []*model.Feed
args []interface{}
stmt string
err error
)
switch meddler.Default {
case meddler.PostgreSQL:
@ -53,7 +57,9 @@ func (db *datastore) GetUserFeedLatest(listof []*model.RepoLite) ([]*model.Feed,
default:
stmt, args = toList(listof)
}
err := meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedLatest, stmt), args...)
if len(args) > 0 {
err = meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedLatest, stmt), args...)
}
return feed, err
}