v0.0.642 Fix wmo createPaginationPipeline not sorting on initial token
Build Docker and Deploy / Run goext test-suite (push) Failing after 27m5s

This commit is contained in:
2026-05-27 17:18:10 +02:00
parent fad2e4ff6d
commit 145b1138d7
2 changed files with 14 additions and 18 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.641"
const GoextVersion = "0.0.642"
const GoextVersionTimestamp = "2026-05-22T22:06:05+0200"
const GoextVersionTimestamp = "2026-05-27T17:18:10+0200"
+12 -16
View File
@@ -402,17 +402,17 @@ func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CTKeySort,
}
if isValidTokenValue(valuePrimary) {
if sortPrimary == ct.SortASC {
// We sort ASC on <field> - so we want all entries newer ($gt) than the $primary
cond = append(cond, bson.M{fieldPrimary: bson.M{"$gt": valuePrimary}})
sort = append(sort, bson.E{Key: fieldPrimary, Value: +1})
cond = append(cond, bson.M{fieldPrimary: bson.M{"$gt": valuePrimary}}) // We sort ASC on <field> - so we want all entries newer ($gt) than the $primary
} else if sortPrimary == ct.SortDESC {
// We sort DESC on <field> - so we want all entries older ($lt) than the $primary
cond = append(cond, bson.M{fieldPrimary: bson.M{"$lt": valuePrimary}})
sort = append(sort, bson.E{Key: fieldPrimary, Value: -1})
cond = append(cond, bson.M{fieldPrimary: bson.M{"$lt": valuePrimary}}) // We sort DESC on <field> - so we want all entries older ($lt) than the $primary
}
}
if sortPrimary == ct.SortASC {
sort = append(sort, bson.E{Key: fieldPrimary, Value: +1}) // We sort ASC on <field> - so we want all entries newer ($gt) than the $primary
} else if sortPrimary == ct.SortDESC {
sort = append(sort, bson.E{Key: fieldPrimary, Value: -1}) // We sort DESC on <field> - so we want all entries older ($lt) than the $primary
}
if fieldSecondary != nil && sortSecondary != nil && *fieldSecondary != fieldPrimary {
@@ -423,29 +423,25 @@ func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CTKeySort,
}
if isValidTokenValue(valueSecondary) {
if *sortSecondary == ct.SortASC {
// the conflict-resolution condition, for entries with the _same_ <field> as the $primary we take the ones with a greater $secondary (= newer)
cond = append(cond, bson.M{"$and": bson.A{
bson.M{"$or": bson.A{bson.M{fieldPrimary: valuePrimary}, bson.M{fieldPrimary: nil}, bson.M{fieldPrimary: bson.M{"$exists": false}}}},
bson.M{*fieldSecondary: bson.M{"$gt": valueSecondary}},
}})
sort = append(sort, bson.E{Key: *fieldSecondary, Value: +1})
} else if *sortSecondary == ct.SortDESC {
// the conflict-resolution condition, for entries with the _same_ <field> as the $primary we take the ones with a smaller $secondary (= older)
cond = append(cond, bson.M{"$and": bson.A{
bson.M{"$or": bson.A{bson.M{fieldPrimary: valuePrimary}, bson.M{fieldPrimary: nil}, bson.M{fieldPrimary: bson.M{"$exists": false}}}},
bson.M{*fieldSecondary: bson.M{"$lt": valueSecondary}},
}})
sort = append(sort, bson.E{Key: *fieldSecondary, Value: -1})
}
}
if *sortSecondary == ct.SortASC {
sort = append(sort, bson.E{Key: *fieldSecondary, Value: +1})
} else if *sortSecondary == ct.SortDESC {
sort = append(sort, bson.E{Key: *fieldSecondary, Value: -1})
}
}