Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
ebba6545a3
|
|||
19c7e22ced
|
|||
9f883b458f
|
|||
1f456c5134
|
@@ -38,6 +38,13 @@ func (ee *ExErr) Error() string {
|
|||||||
// Unwrap must be implemented so that some error.XXX methods work
|
// Unwrap must be implemented so that some error.XXX methods work
|
||||||
func (ee *ExErr) Unwrap() error {
|
func (ee *ExErr) Unwrap() error {
|
||||||
if ee.OriginalError == nil {
|
if ee.OriginalError == nil {
|
||||||
|
|
||||||
|
if ee.WrappedErr != nil {
|
||||||
|
if werr, ok := ee.WrappedErr.(error); ok {
|
||||||
|
return werr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil // this is neccessary - otherwise we return a wrapped nil and the `x == nil` comparison fails (= panic in errors.Is and other failures)
|
return nil // this is neccessary - otherwise we return a wrapped nil and the `x == nil` comparison fails (= panic in errors.Is and other failures)
|
||||||
}
|
}
|
||||||
return ee.OriginalError
|
return ee.OriginalError
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.511"
|
const GoextVersion = "0.0.515"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-09-15T18:22:07+0200"
|
const GoextVersionTimestamp = "2024-09-16T17:39:51+0200"
|
||||||
|
@@ -788,7 +788,7 @@ FieldLoop:
|
|||||||
|
|
||||||
if f.omitEmpty && isEmptyValue(fv) {
|
if f.omitEmpty && isEmptyValue(fv) {
|
||||||
continue
|
continue
|
||||||
} else if opts.filter != nil && !matchesJSONFilter(f.jsonfilter, *opts.filter) {
|
} else if !matchesJSONFilter(f.jsonfilter, opts.filter) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
e.WriteByte(next)
|
e.WriteByte(next)
|
||||||
@@ -808,16 +808,20 @@ FieldLoop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchesJSONFilter(filter jsonfilter, value string) bool {
|
func matchesJSONFilter(filter jsonfilter, value *string) bool {
|
||||||
if len(filter) == 0 {
|
if len(filter) == 0 {
|
||||||
return true
|
return true // no filter in struct
|
||||||
|
}
|
||||||
|
|
||||||
|
if value == nil || *value == "" {
|
||||||
|
return false // no filter set, but struct has filter, return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(filter) == 1 && filter[0] == "-" {
|
if len(filter) == 1 && filter[0] == "-" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if filter.Contains(value) {
|
if filter.Contains(*value) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -215,7 +215,7 @@ func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CursorToken
|
|||||||
|
|
||||||
// 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{fieldPrimary: valuePrimary},
|
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}},
|
||||||
}})
|
}})
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ func createPaginationPipeline[TData any](coll *Coll[TData], token ct.CursorToken
|
|||||||
|
|
||||||
// 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{fieldPrimary: valuePrimary},
|
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}},
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user