more robust ordering on categories
This commit is contained in:
parent
e75c81fa36
commit
ff9c3e7f77
|
@ -22,7 +22,7 @@ func LoadCategories(db *sql.DB) {
|
|||
CategoriesTree = []*Category{}
|
||||
CategoriesFlat = make(map[int]*Category)
|
||||
|
||||
rows, err := db.Query("select categories.id, categories.name, categories.parent_id from categories order by id,Categories.parent_id desc")
|
||||
rows, err := db.Query("select categories.id, categories.name, categories.parent_id from categories order by coalesce(parent_id, id), parent_id is not null")
|
||||
if err != nil {
|
||||
fmt.Println("DB Error loading Categories:", err)
|
||||
return
|
||||
|
@ -36,7 +36,7 @@ func LoadCategories(db *sql.DB) {
|
|||
if err != nil {
|
||||
fmt.Println("Categories DB Error: ", err)
|
||||
}
|
||||
|
||||
|
||||
CategoriesFlat[category.Id] = category
|
||||
|
||||
if category.Parent.Valid {
|
||||
|
|
Loading…
Reference in New Issue