From 5af92280140c21253b0ba4915312161d65233cd3 Mon Sep 17 00:00:00 2001 From: Hein Date: Sat, 3 Jan 2026 20:53:32 +0200 Subject: [PATCH] fix(templ): :bug: fixed the sorting that turns nothing. template functions expects something returned --- pkg/models/sorting.go | 60 +++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/pkg/models/sorting.go b/pkg/models/sorting.go index 25cedd4..2b0e521 100644 --- a/pkg/models/sorting.go +++ b/pkg/models/sorting.go @@ -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 }