Eliminate duplicate results
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2022-12-24 13:04:34 -08:00
parent 8366a2ce86
commit acb71b873e
1 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ func InsertPackage(db *sqlx.DB, pkg Package) error {
// GetPkgs returns a result containing packages that match the where conditions
func GetPkgs(db *sqlx.DB, where string, args ...any) (*sqlx.Rows, error) {
stream, err := db.Queryx("SELECT * FROM pkgs, json_each(pkgs.provides) AS provides WHERE "+where, args...)
stream, err := db.Queryx("SELECT DISTINCT * FROM pkgs, json_each(pkgs.provides) AS provides WHERE "+where, args...)
if err != nil {
return nil, err
}
@ -108,7 +108,7 @@ func GetPkgs(db *sqlx.DB, where string, args ...any) (*sqlx.Rows, error) {
// GetPkg returns a single package that match the where conditions
func GetPkg(db *sqlx.DB, where string, args ...any) (*Package, error) {
out := &Package{}
err := db.Get(out, "SELECT * FROM pkgs, json_each(pkgs.provides) AS provides WHERE "+where+"LIMIT 1", args...)
err := db.Get(out, "SELECT DISTINCT * FROM pkgs, json_each(pkgs.provides) AS provides WHERE "+where+"LIMIT 1", args...)
return out, err
}