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:
Mazyar
2026-06-06 09:41:12 +03:30
parent 97f761adbe
commit 5af3bfaa1a
2 changed files with 27 additions and 1 deletions
+26
View File
@@ -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)
}
}