Migrate to PostgreSQL and fix related issues
This commit is contained in:
parent
0b8fbea6c3
commit
a89a9776c3
17 changed files with 176 additions and 174 deletions
|
|
@ -18,7 +18,7 @@ func Sections(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var sections []models.Section
|
||||
result := db.Order("name collate nocase asc").Preload("ParentSection").Find(§ions)
|
||||
result := db.Order("name asc").Preload("ParentSection").Find(§ions)
|
||||
|
||||
if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
|
|
@ -70,8 +70,8 @@ func SectionAdd(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(
|
||||
§ions, "id <> ? AND parent_section_id = 0", section.ID,
|
||||
db.Order("name asc").Find(
|
||||
§ions, "id <> ? AND parent_section_id IS NULL", section.ID,
|
||||
)
|
||||
|
||||
if c.Method() == "POST" {
|
||||
|
|
@ -106,12 +106,12 @@ func SectionAdd(c *fiber.Ctx) error {
|
|||
section.Name = name
|
||||
section.ShortName = shortName
|
||||
|
||||
section.ParentSectionID = 0
|
||||
parentSectionID, err := strconv.ParseUint(parentSection, 10, 0)
|
||||
if err == nil {
|
||||
for _, parentSection := range sections {
|
||||
if parentSection.ID == uint(parentSectionID) {
|
||||
section.ParentSectionID = uint(parentSectionID)
|
||||
parentSectionID2 := uint(parentSectionID)
|
||||
if parentSection.ID == parentSectionID2 {
|
||||
section.ParentSectionID = &parentSectionID2
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -177,8 +177,8 @@ func SectionEdit(c *fiber.Ctx) error {
|
|||
)
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(
|
||||
§ions, "id <> ? AND parent_section_id = 0", section.ID,
|
||||
db.Order("name asc").Find(
|
||||
§ions, "id <> ? AND parent_section_id IS NULL", section.ID,
|
||||
)
|
||||
|
||||
var errors []string
|
||||
|
|
@ -200,12 +200,12 @@ func SectionEdit(c *fiber.Ctx) error {
|
|||
section.Name = name
|
||||
section.ShortName = shortName
|
||||
|
||||
section.ParentSectionID = 0
|
||||
parentSectionID, err := strconv.ParseUint(parentSection, 10, 0)
|
||||
if err == nil {
|
||||
for _, parentSection := range sections {
|
||||
if parentSection.ID == uint(parentSectionID) {
|
||||
section.ParentSectionID = uint(parentSectionID)
|
||||
parentSectionID2 := uint(parentSectionID)
|
||||
if parentSection.ID == parentSectionID2 {
|
||||
section.ParentSectionID = &parentSectionID2
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue