v0.0.642 Fix wmo createPaginationPipeline not sorting on initial token
Build Docker and Deploy / Run goext test-suite (push) Failing after 27m5s
Build Docker and Deploy / Run goext test-suite (push) Failing after 27m5s
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
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
@@ -402,17 +402,17 @@ func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CTKeySort,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isValidTokenValue(valuePrimary) {
|
if isValidTokenValue(valuePrimary) {
|
||||||
|
|
||||||
if sortPrimary == ct.SortASC {
|
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}}) // 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})
|
|
||||||
} else if sortPrimary == ct.SortDESC {
|
} 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}}) // 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})
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
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 isValidTokenValue(valueSecondary) {
|
||||||
|
|
||||||
if *sortSecondary == ct.SortASC {
|
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)
|
// 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{
|
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{"$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}},
|
bson.M{*fieldSecondary: bson.M{"$gt": valueSecondary}},
|
||||||
}})
|
}})
|
||||||
|
|
||||||
sort = append(sort, bson.E{Key: *fieldSecondary, Value: +1})
|
|
||||||
|
|
||||||
} else if *sortSecondary == ct.SortDESC {
|
} 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)
|
// 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{
|
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{"$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}},
|
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})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user