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

pull/2715/head
BoYanZh 2022-12-14 10:37:09 +08:00 committed by GitHub
parent 7947ff1ae4
commit cdc45630ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

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 {