refactor(query): streamline query construction for tag filtering
This commit is contained in:
parent
712e31cc60
commit
b4a05166a4
@ -147,14 +147,10 @@ func InSet(field string, values []string) func(db *gorm.DB) *gorm.DB {
|
|||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
query := db
|
query := db.Where("1=0")
|
||||||
for i, v := range values {
|
for _, v := range values {
|
||||||
if i == 0 {
|
|
||||||
query = query.Where("FIND_IN_SET(?, "+field+")", v)
|
|
||||||
} else {
|
|
||||||
query = query.Or("FIND_IN_SET(?, "+field+")", v)
|
query = query.Or("FIND_IN_SET(?, "+field+")", v)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user