fix: whereInParent when parent = "/" (#2706)

This commit is contained in:
BoYanZh
2022-12-14 10:37:09 +08:00
committed by GitHub
parent 7947ff1ae4
commit cdc45630ae

View File

@ -12,10 +12,12 @@ import (
)
func whereInParent(parent string) *gorm.DB {
if parent == "/" {
return db.Where("1 = 1")
}
return db.Where(fmt.Sprintf("%s LIKE ?", columnName("parent")),
fmt.Sprintf("%s/%%", parent)).
Or(fmt.Sprintf("%s = ?", columnName("parent")),
fmt.Sprintf("%s%%", parent))
Or(fmt.Sprintf("%s = ?", columnName("parent")), parent)
}
func CreateSearchNode(node *model.SearchNode) error {