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
|
|
@ -69,7 +69,7 @@ func Contacts(c *fiber.Ctx) error {
|
|||
params.PersonType = "contacts"
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(§ions, "contains_contacts = ? AND id IN ?", true, allowedSections)
|
||||
db.Order("name asc").Find(§ions, "contains_contacts = ? AND id IN ?", true, allowedSections)
|
||||
params.AllowedSections = allowedSections
|
||||
|
||||
// Security for active contacts
|
||||
|
|
@ -156,7 +156,7 @@ func ContactsExport(c *fiber.Ctx) error {
|
|||
params.PersonType = "contacts"
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(§ions, "contains_members = ? AND id IN ?", true, allowedSections)
|
||||
db.Order("name asc").Find(§ions, "contains_members = ? AND id IN ?", true, allowedSections)
|
||||
params.AllowedSections = allowedSections
|
||||
|
||||
// Security for active contacts
|
||||
|
|
@ -280,7 +280,7 @@ func ContactsExport(c *fiber.Ctx) error {
|
|||
|
||||
} else if field.FieldType == "list" {
|
||||
|
||||
if field.List.Multi {
|
||||
if field.List != nil && field.List.Multi {
|
||||
|
||||
if countMulti == 0 {
|
||||
c.Writef("\"")
|
||||
|
|
@ -323,7 +323,7 @@ func ContactShow(c *fiber.Ctx) error {
|
|||
|
||||
var person models.Person
|
||||
result := db.Unscoped().Preload("Section").Find(
|
||||
&person, "id = ? AND is_contact", id, true,
|
||||
&person, "id = ? AND is_contact = ?", id, true,
|
||||
)
|
||||
|
||||
if result.Error != nil {
|
||||
|
|
@ -416,7 +416,7 @@ func ContactAdd(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(
|
||||
db.Order("name asc").Find(
|
||||
§ions,
|
||||
"contains_contacts = ?",
|
||||
true,
|
||||
|
|
@ -511,7 +511,7 @@ func ContactAdd(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
for _, field := range fields {
|
||||
if field.List.Multi {
|
||||
if field.List != nil && field.List.Multi {
|
||||
for _, listItem := range field.List.ListItems {
|
||||
key := fmt.Sprintf("field-%d-%d", field.ID, listItem.ID)
|
||||
value := c.FormValue(key)
|
||||
|
|
@ -520,7 +520,7 @@ func ContactAdd(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = listItem.ID
|
||||
fieldValue.ListItemID = &listItem.ID
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
@ -594,7 +594,8 @@ func ContactAdd(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = uint(valueInt)
|
||||
valueUint := uint(valueInt)
|
||||
fieldValue.ListItemID = &valueUint
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
@ -659,7 +660,7 @@ func ContactEdit(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(
|
||||
db.Order("name asc").Find(
|
||||
§ions,
|
||||
"contains_contacts = ?",
|
||||
true,
|
||||
|
|
@ -760,7 +761,7 @@ func ContactEdit(c *fiber.Ctx) error {
|
|||
field.ID,
|
||||
)
|
||||
|
||||
if field.List.Multi {
|
||||
if field.List != nil && field.List.Multi {
|
||||
for _, listItem := range field.List.ListItems {
|
||||
key := fmt.Sprintf("field-%d-%d", field.ID, listItem.ID)
|
||||
value := c.FormValue(key)
|
||||
|
|
@ -769,7 +770,7 @@ func ContactEdit(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = listItem.ID
|
||||
fieldValue.ListItemID = &listItem.ID
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
@ -843,7 +844,8 @@ func ContactEdit(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = uint(valueInt)
|
||||
valueUint := uint(valueInt)
|
||||
fieldValue.ListItemID = &valueUint
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ func DebugFixFieldsOrder(c *fiber.Ctx) error {
|
|||
|
||||
var memberFields []models.Field
|
||||
result := db.Order(
|
||||
"name collate nocase asc",
|
||||
"name asc",
|
||||
).Find(
|
||||
&memberFields, "person_type = ?", "member",
|
||||
)
|
||||
|
|
@ -130,7 +130,7 @@ func DebugFixFieldsOrder(c *fiber.Ctx) error {
|
|||
|
||||
var contactFields []models.Field
|
||||
result2 := db.Order(
|
||||
"name collate nocase asc",
|
||||
"name asc",
|
||||
).Find(
|
||||
&contactFields, "person_type = ?", "contact",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func FieldAdd(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var lists []models.List
|
||||
db.Order("name collate nocase asc").Find(&lists)
|
||||
db.Order("name asc").Find(&lists)
|
||||
|
||||
if c.Method() == "POST" {
|
||||
field.Name = c.FormValue("name")
|
||||
|
|
@ -107,7 +107,8 @@ func FieldAdd(c *fiber.Ctx) error {
|
|||
if err != nil || listID < 1 {
|
||||
errors = append(errors, "Liste incorrecte")
|
||||
} else {
|
||||
field.ListID = uint(listID)
|
||||
listID2 := uint(listID)
|
||||
field.ListID = &listID2
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ func Lists(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var lists []models.List
|
||||
result := db.Order("name collate nocase asc").Find(&lists)
|
||||
result := db.Order("name asc").Find(&lists)
|
||||
|
||||
if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
|
|
@ -54,7 +54,7 @@ func ListShow(c *fiber.Ctx) error {
|
|||
)
|
||||
|
||||
var listItems []models.ListItem
|
||||
db.Order("value collate nocase asc").Find(&listItems, "list_id = ?", id)
|
||||
db.Order("value asc").Find(&listItems, "list_id = ?", id)
|
||||
|
||||
return c.Render("list", fiber.Map{
|
||||
"PageTitle": title,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func Members(c *fiber.Ctx) error {
|
|||
params.PersonType = "members"
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(§ions, "contains_members = ? AND id IN ?", true, allowedSections)
|
||||
db.Order("name asc").Find(§ions, "contains_members = ? AND id IN ?", true, allowedSections)
|
||||
params.AllowedSections = allowedSections
|
||||
|
||||
// Security for active contacts
|
||||
|
|
@ -171,7 +171,7 @@ func MembersExport(c *fiber.Ctx) error {
|
|||
params.PersonType = "members"
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(§ions, "contains_members = ? AND id IN ?", true, allowedSections)
|
||||
db.Order("name asc").Find(§ions, "contains_members = ? AND id IN ?", true, allowedSections)
|
||||
params.AllowedSections = allowedSections
|
||||
|
||||
// Security for active contacts
|
||||
|
|
@ -338,7 +338,7 @@ func MemberShow(c *fiber.Ctx) error {
|
|||
|
||||
var person models.Person
|
||||
result := db.Unscoped().Preload("Section").Find(
|
||||
&person, "id = ? AND is_member", id, true,
|
||||
&person, "id = ? AND is_member = ?", id, true,
|
||||
)
|
||||
|
||||
if result.Error != nil {
|
||||
|
|
@ -431,7 +431,7 @@ func MemberAdd(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(
|
||||
db.Order("name asc").Find(
|
||||
§ions,
|
||||
"contains_members = ?",
|
||||
true,
|
||||
|
|
@ -526,7 +526,7 @@ func MemberAdd(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
for _, field := range fields {
|
||||
if field.List.Multi {
|
||||
if field.List != nil && field.List.Multi {
|
||||
for _, listItem := range field.List.ListItems {
|
||||
key := fmt.Sprintf("field-%d-%d", field.ID, listItem.ID)
|
||||
value := c.FormValue(key)
|
||||
|
|
@ -535,7 +535,7 @@ func MemberAdd(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = listItem.ID
|
||||
fieldValue.ListItemID = &listItem.ID
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
@ -609,7 +609,8 @@ func MemberAdd(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = uint(valueInt)
|
||||
valueUint := uint(valueInt)
|
||||
fieldValue.ListItemID = &valueUint
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
@ -674,7 +675,7 @@ func MemberEdit(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(
|
||||
db.Order("name asc").Find(
|
||||
§ions,
|
||||
"contains_members = ?",
|
||||
true,
|
||||
|
|
@ -775,7 +776,7 @@ func MemberEdit(c *fiber.Ctx) error {
|
|||
field.ID,
|
||||
)
|
||||
|
||||
if field.List.Multi {
|
||||
if field.List != nil && field.List.Multi {
|
||||
for _, listItem := range field.List.ListItems {
|
||||
key := fmt.Sprintf("field-%d-%d", field.ID, listItem.ID)
|
||||
value := c.FormValue(key)
|
||||
|
|
@ -784,7 +785,7 @@ func MemberEdit(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = listItem.ID
|
||||
fieldValue.ListItemID = &listItem.ID
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
@ -858,7 +859,8 @@ func MemberEdit(c *fiber.Ctx) error {
|
|||
var fieldValue models.FieldValue
|
||||
fieldValue.FieldID = field.ID
|
||||
fieldValue.PersonID = person.ID
|
||||
fieldValue.ListItemID = uint(valueInt)
|
||||
valueUint := uint(valueInt)
|
||||
fieldValue.ListItemID = &valueUint
|
||||
db.Create(&fieldValue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ func Roles(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var roles []models.Role
|
||||
result := db.Order("name collate nocase asc").Find(&roles)
|
||||
result := db.Order("name asc").Find(&roles)
|
||||
|
||||
if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func Users(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
var users []models.User
|
||||
result := db.Order("name collate nocase asc").Find(&users)
|
||||
result := db.Order("name asc").Find(&users)
|
||||
|
||||
if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
|
|
@ -62,7 +62,7 @@ func UserShow(c *fiber.Ctx) error {
|
|||
)
|
||||
|
||||
var userRoles []models.UserRole
|
||||
db.Joins("Role").Joins("Section").Order("Section__name collate nocase asc").Find(
|
||||
db.Joins("Role").Joins("Section").Order("\"Section\".\"name\" asc").Find(
|
||||
&userRoles, "user_id = ?", id,
|
||||
)
|
||||
|
||||
|
|
@ -284,10 +284,10 @@ func UserPermissions(c *fiber.Ctx) error {
|
|||
)
|
||||
|
||||
var roles []models.Role
|
||||
db.Order("name collate nocase asc").Find(&roles)
|
||||
db.Order("name asc").Find(&roles)
|
||||
|
||||
var sections []models.Section
|
||||
db.Order("name collate nocase asc").Find(§ions)
|
||||
db.Order("name asc").Find(§ions)
|
||||
|
||||
var errors []string
|
||||
if c.Method() == "POST" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue