From ff1a21833d64d2499241370032931c3df1101afe Mon Sep 17 00:00:00 2001 From: Kobs Date: Fri, 5 Dec 2025 10:19:14 +0100 Subject: [PATCH] Numeric ordering collation option --- worker/sai-storage-mongo/external/adapter/types.go | 9 +++++---- worker/sai-storage-mongo/mongo/client.go | 4 ++++ worker/sai-storage-mongo/types/mongo.go | 9 +++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/worker/sai-storage-mongo/external/adapter/types.go b/worker/sai-storage-mongo/external/adapter/types.go index 0ce05ef..3017f30 100644 --- a/worker/sai-storage-mongo/external/adapter/types.go +++ b/worker/sai-storage-mongo/external/adapter/types.go @@ -19,10 +19,11 @@ type Request struct { } type Options struct { - Limit int64 `json:"limit"` - Skip int64 `json:"skip"` - Sort interface{} `json:"sort"` - Count int64 `json:"count"` + Limit int64 `json:"limit"` + Skip int64 `json:"skip"` + Sort interface{} `json:"sort"` + Count int64 `json:"count"` + NumericOrdering bool `json:"numeric_ordering"` } func (r Request) GetMethod() string { diff --git a/worker/sai-storage-mongo/mongo/client.go b/worker/sai-storage-mongo/mongo/client.go index c05c52c..b3f63fe 100644 --- a/worker/sai-storage-mongo/mongo/client.go +++ b/worker/sai-storage-mongo/mongo/client.go @@ -150,6 +150,10 @@ func (c Client) Find(collectionName string, selector map[string]interface{}, inp requestOptions.SetProjection(projection) } + if inputOptions.NumericOrdering { + requestOptions.Collation.NumericOrdering = true + } + collection := c.GetCollection(collectionName) selector = c.preprocessSelector(selector) diff --git a/worker/sai-storage-mongo/types/mongo.go b/worker/sai-storage-mongo/types/mongo.go index 25d7d52..1662750 100644 --- a/worker/sai-storage-mongo/types/mongo.go +++ b/worker/sai-storage-mongo/types/mongo.go @@ -6,8 +6,9 @@ type FindResult struct { } type Options struct { - Limit int64 `json:"limit"` - Skip int64 `json:"skip"` - Sort interface{} `json:"sort"` - Count int64 `json:"count"` + Limit int64 `json:"limit"` + Skip int64 `json:"skip"` + Sort interface{} `json:"sort"` + Count int64 `json:"count"` + NumericOrdering bool `json:"numeric_ordering"` }