Skip to content

Commit

Permalink
Merge pull request harness#1929 from josmo/remove_size_limit
Browse files Browse the repository at this point in the history
Remove size limit
  • Loading branch information
bradrydzewski authored Feb 23, 2017
2 parents 24507d9 + 488ce87 commit f9770b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion store/datastore/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (db *datastore) GetRepoListOf(listof []*model.RepoLite) ([]*model.Repo, err
)
switch meddler.Default {
case meddler.PostgreSQL:
stmt, args = toListPosgres(listof)
stmt, args = toListPostgres(listof)
default:
stmt, args = toList(listof)
}
Expand Down
4 changes: 2 additions & 2 deletions store/datastore/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (db *datastore) GetUserFeed(listof []*model.RepoLite) ([]*model.Feed, error
)
switch meddler.Default {
case meddler.PostgreSQL:
stmt, args = toListPosgres(listof)
stmt, args = toListPostgres(listof)
default:
stmt, args = toList(listof)
}
Expand All @@ -55,7 +55,7 @@ func (db *datastore) GetUserFeedLatest(listof []*model.RepoLite) ([]*model.Feed,
)
switch meddler.Default {
case meddler.PostgreSQL:
stmt, args = toListPosgres(listof)
stmt, args = toListPostgres(listof)
default:
stmt, args = toList(listof)
}
Expand Down
14 changes: 9 additions & 5 deletions store/datastore/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ func rebind(query string) string {
// to a sql IN statment.
func toList(listof []*model.RepoLite) (string, []interface{}) {
var size = len(listof)
if size > 999 {
switch {
case meddler.Default == meddler.SQLite && size > 999:
size = 999
listof = listof[:999]
case size > 15000:
size = 15000
listof = listof[:15000]
}
var qs = make([]string, size, size)
var in = make([]interface{}, size, size)
Expand All @@ -55,11 +59,11 @@ func toList(listof []*model.RepoLite) (string, []interface{}) {

// helper function that converts a simple repository list
// to a sql IN statement compatible with postgres.
func toListPosgres(listof []*model.RepoLite) (string, []interface{}) {
func toListPostgres(listof []*model.RepoLite) (string, []interface{}) {
var size = len(listof)
if size > 999 {
size = 999
listof = listof[:999]
if size > 15000 {
size = 15000
listof = listof[:15000]
}
var qs = make([]string, size, size)
var in = make([]interface{}, size, size)
Expand Down

0 comments on commit f9770b0

Please sign in to comment.