fix(templ): 🐛 fixed the sorting that turns nothing. template functions expects something returned
Some checks failed
CI / Test (1.24) (pull_request) Failing after 1m40s
CI / Build (pull_request) Failing after 39s
CI / Lint (pull_request) Successful in -25m59s
CI / Test (1.25) (pull_request) Successful in -25m11s
Integration Tests / Integration Tests (pull_request) Failing after 1m17s

This commit is contained in:
2026-01-03 20:53:32 +02:00
parent fca7c99d74
commit 5af9228014

View File

@@ -18,7 +18,7 @@ const (
// Schema Sorting
// SortSchemasByName sorts schemas by name
func SortSchemasByName(schemas []*Schema, desc bool) {
func SortSchemasByName(schemas []*Schema, desc bool) error {
sort.SliceStable(schemas, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(schemas[i].Name), strings.ToLower(schemas[j].Name))
if desc {
@@ -26,22 +26,24 @@ func SortSchemasByName(schemas []*Schema, desc bool) {
}
return cmp < 0
})
return nil
}
// SortSchemasBySequence sorts schemas by sequence number
func SortSchemasBySequence(schemas []*Schema, desc bool) {
func SortSchemasBySequence(schemas []*Schema, desc bool) error {
sort.SliceStable(schemas, func(i, j int) bool {
if desc {
return schemas[i].Sequence > schemas[j].Sequence
}
return schemas[i].Sequence < schemas[j].Sequence
})
return nil
}
// Table Sorting
// SortTablesByName sorts tables by name
func SortTablesByName(tables []*Table, desc bool) {
func SortTablesByName(tables []*Table, desc bool) error {
sort.SliceStable(tables, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(tables[i].Name), strings.ToLower(tables[j].Name))
if desc {
@@ -49,16 +51,18 @@ func SortTablesByName(tables []*Table, desc bool) {
}
return cmp < 0
})
return nil
}
// SortTablesBySequence sorts tables by sequence number
func SortTablesBySequence(tables []*Table, desc bool) {
func SortTablesBySequence(tables []*Table, desc bool) error {
sort.SliceStable(tables, func(i, j int) bool {
if desc {
return tables[i].Sequence > tables[j].Sequence
}
return tables[i].Sequence < tables[j].Sequence
})
return nil
}
// Column Sorting
@@ -69,7 +73,7 @@ func SortColumnsMapByName(columns map[string]*Column, desc bool) []*Column {
for _, col := range columns {
result = append(result, col)
}
SortColumnsByName(result, desc)
_ = SortColumnsByName(result, desc)
return result
}
@@ -79,12 +83,12 @@ func SortColumnsMapBySequence(columns map[string]*Column, desc bool) []*Column {
for _, col := range columns {
result = append(result, col)
}
SortColumnsBySequence(result, desc)
_ = SortColumnsBySequence(result, desc)
return result
}
// SortColumnsByName sorts columns by name
func SortColumnsByName(columns []*Column, desc bool) {
func SortColumnsByName(columns []*Column, desc bool) error {
sort.SliceStable(columns, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(columns[i].Name), strings.ToLower(columns[j].Name))
if desc {
@@ -92,22 +96,24 @@ func SortColumnsByName(columns []*Column, desc bool) {
}
return cmp < 0
})
return nil
}
// SortColumnsBySequence sorts columns by sequence number
func SortColumnsBySequence(columns []*Column, desc bool) {
func SortColumnsBySequence(columns []*Column, desc bool) error {
sort.SliceStable(columns, func(i, j int) bool {
if desc {
return columns[i].Sequence > columns[j].Sequence
}
return columns[i].Sequence < columns[j].Sequence
})
return nil
}
// View Sorting
// SortViewsByName sorts views by name
func SortViewsByName(views []*View, desc bool) {
func SortViewsByName(views []*View, desc bool) error {
sort.SliceStable(views, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(views[i].Name), strings.ToLower(views[j].Name))
if desc {
@@ -115,22 +121,24 @@ func SortViewsByName(views []*View, desc bool) {
}
return cmp < 0
})
return nil
}
// SortViewsBySequence sorts views by sequence number
func SortViewsBySequence(views []*View, desc bool) {
func SortViewsBySequence(views []*View, desc bool) error {
sort.SliceStable(views, func(i, j int) bool {
if desc {
return views[i].Sequence > views[j].Sequence
}
return views[i].Sequence < views[j].Sequence
})
return nil
}
// Sequence Sorting
// SortSequencesByName sorts sequences by name
func SortSequencesByName(sequences []*Sequence, desc bool) {
func SortSequencesByName(sequences []*Sequence, desc bool) error {
sort.SliceStable(sequences, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(sequences[i].Name), strings.ToLower(sequences[j].Name))
if desc {
@@ -138,16 +146,18 @@ func SortSequencesByName(sequences []*Sequence, desc bool) {
}
return cmp < 0
})
return nil
}
// SortSequencesBySequence sorts sequences by sequence number
func SortSequencesBySequence(sequences []*Sequence, desc bool) {
func SortSequencesBySequence(sequences []*Sequence, desc bool) error {
sort.SliceStable(sequences, func(i, j int) bool {
if desc {
return sequences[i].Sequence > sequences[j].Sequence
}
return sequences[i].Sequence < sequences[j].Sequence
})
return nil
}
// Index Sorting
@@ -158,7 +168,7 @@ func SortIndexesMapByName(indexes map[string]*Index, desc bool) []*Index {
for _, idx := range indexes {
result = append(result, idx)
}
SortIndexesByName(result, desc)
_ = SortIndexesByName(result, desc)
return result
}
@@ -168,12 +178,12 @@ func SortIndexesMapBySequence(indexes map[string]*Index, desc bool) []*Index {
for _, idx := range indexes {
result = append(result, idx)
}
SortIndexesBySequence(result, desc)
_ = SortIndexesBySequence(result, desc)
return result
}
// SortIndexesByName sorts indexes by name
func SortIndexesByName(indexes []*Index, desc bool) {
func SortIndexesByName(indexes []*Index, desc bool) error {
sort.SliceStable(indexes, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(indexes[i].Name), strings.ToLower(indexes[j].Name))
if desc {
@@ -181,16 +191,18 @@ func SortIndexesByName(indexes []*Index, desc bool) {
}
return cmp < 0
})
return nil
}
// SortIndexesBySequence sorts indexes by sequence number
func SortIndexesBySequence(indexes []*Index, desc bool) {
func SortIndexesBySequence(indexes []*Index, desc bool) error {
sort.SliceStable(indexes, func(i, j int) bool {
if desc {
return indexes[i].Sequence > indexes[j].Sequence
}
return indexes[i].Sequence < indexes[j].Sequence
})
return nil
}
// Constraint Sorting
@@ -201,12 +213,12 @@ func SortConstraintsMapByName(constraints map[string]*Constraint, desc bool) []*
for _, c := range constraints {
result = append(result, c)
}
SortConstraintsByName(result, desc)
_ = SortConstraintsByName(result, desc)
return result
}
// SortConstraintsByName sorts constraints by name
func SortConstraintsByName(constraints []*Constraint, desc bool) {
func SortConstraintsByName(constraints []*Constraint, desc bool) error {
sort.SliceStable(constraints, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(constraints[i].Name), strings.ToLower(constraints[j].Name))
if desc {
@@ -214,6 +226,7 @@ func SortConstraintsByName(constraints []*Constraint, desc bool) {
}
return cmp < 0
})
return nil
}
// Relationship Sorting
@@ -224,12 +237,12 @@ func SortRelationshipsMapByName(relationships map[string]*Relationship, desc boo
for _, r := range relationships {
result = append(result, r)
}
SortRelationshipsByName(result, desc)
_ = SortRelationshipsByName(result, desc)
return result
}
// SortRelationshipsByName sorts relationships by name
func SortRelationshipsByName(relationships []*Relationship, desc bool) {
func SortRelationshipsByName(relationships []*Relationship, desc bool) error {
sort.SliceStable(relationships, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(relationships[i].Name), strings.ToLower(relationships[j].Name))
if desc {
@@ -237,12 +250,13 @@ func SortRelationshipsByName(relationships []*Relationship, desc bool) {
}
return cmp < 0
})
return nil
}
// Script Sorting
// SortScriptsByName sorts scripts by name
func SortScriptsByName(scripts []*Script, desc bool) {
func SortScriptsByName(scripts []*Script, desc bool) error {
sort.SliceStable(scripts, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(scripts[i].Name), strings.ToLower(scripts[j].Name))
if desc {
@@ -250,12 +264,13 @@ func SortScriptsByName(scripts []*Script, desc bool) {
}
return cmp < 0
})
return nil
}
// Enum Sorting
// SortEnumsByName sorts enums by name
func SortEnumsByName(enums []*Enum, desc bool) {
func SortEnumsByName(enums []*Enum, desc bool) error {
sort.SliceStable(enums, func(i, j int) bool {
cmp := strings.Compare(strings.ToLower(enums[i].Name), strings.ToLower(enums[j].Name))
if desc {
@@ -263,4 +278,5 @@ func SortEnumsByName(enums []*Enum, desc bool) {
}
return cmp < 0
})
return nil
}