Allow address.country and address.state as company sort fields.
Frontend sends nested address field names for sorting; accept them alongside the existing country and state aliases. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -53,3 +53,29 @@ func TestHashFilterStable(t *testing.T) {
|
||||
t.Fatalf("expected stable non-empty hash, got %q and %q", a, b)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentSortValueNestedField(t *testing.T) {
|
||||
doc := bson.M{
|
||||
"_id": bson.NewObjectID(),
|
||||
"address": bson.M{
|
||||
"country": "US",
|
||||
"state": "NY",
|
||||
},
|
||||
}
|
||||
|
||||
country, err := documentSortValue(doc, "address.country")
|
||||
if err != nil {
|
||||
t.Fatalf("address.country: %v", err)
|
||||
}
|
||||
if country != "US" {
|
||||
t.Fatalf("expected US, got %v", country)
|
||||
}
|
||||
|
||||
state, err := documentSortValue(doc, "address.state")
|
||||
if err != nil {
|
||||
t.Fatalf("address.state: %v", err)
|
||||
}
|
||||
if state != "NY" {
|
||||
t.Fatalf("expected NY, got %v", state)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user