Skip to content

Commit

Permalink
fixed bug in sorting commits, and in deciding when to use "between" i…
Browse files Browse the repository at this point in the history
…nstead of
  • Loading branch information
tzahij committed Oct 20, 2020
1 parent d440053 commit 47bb5af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions catalog/db_branch_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ func getRelevantCommitsCondition(tx db.Tx, branchID int64, commitID CommitID) (s
} else {
maxCommitId = commitID
}
sql := "SELECT commit_id::text FROM catalog_commits WHERE branch_id = $1 AND commit_id <= $2 ORDER BY commit_id"
// commit_id name is changed so that sorting will be performed on the numeric value, not the string value (where "10" is less than "2")
sql := "SELECT commit_id::text as str_commit_id FROM catalog_commits WHERE branch_id = $1 AND commit_id <= $2 ORDER BY commit_id"
err := tx.Select(&commits, sql, branchID, maxCommitId)
if err != nil {
panic(err)
}
if commitID == UncommittedID {
commits = append(commits, strconv.FormatInt(int64(MaxCommitID), 10))
}
if len(commits) > MaxCommitsInFilter {
if len(commits) < MaxCommitsInFilter {
commitsWhere = "min_commit in (" + strings.Join(commits, `,`) + ")"
} else {
commitsWhere = "min_commit BETWEEN 1 AND " + commits[len(commits)-1]
Expand Down

0 comments on commit 47bb5af

Please sign in to comment.