From 5b59819e2d603ef55c4cf056b70af6a08d335373 Mon Sep 17 00:00:00 2001 From: Baha Aiman Date: Mon, 11 Nov 2024 11:56:29 -0800 Subject: [PATCH] fix(firestore): Allow using != with nil (#11112) --- firestore/integration_test.go | 1 + firestore/query.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/firestore/integration_test.go b/firestore/integration_test.go index 2ada3830a8fd..d2a9ab727cb2 100644 --- a/firestore/integration_test.go +++ b/firestore/integration_test.go @@ -1394,6 +1394,7 @@ func TestIntegration_QueryUnary(t *testing.T) { want map[string]interface{} }{ {base.Where("q", "==", nil), wantNull}, + {base.Where("q", "!=", nil), wantNull}, {base.Where("q", "==", math.NaN()), wantNaN}, } { got, err := test.q.Documents(ctx).GetAll() diff --git a/firestore/query.go b/firestore/query.go index 021747e46723..4b174d2a6b21 100644 --- a/firestore/query.go +++ b/firestore/query.go @@ -1114,7 +1114,7 @@ func (f PropertyPathFilter) toProto() (*pb.StructuredQuery_Filter, error) { return nil, err } if uop, ok := unaryOpFor(f.Value); ok { - if f.Operator != "==" { + if f.Operator != "==" && !(f.Operator == "!=" && f.Value == nil) { return nil, fmt.Errorf("firestore: must use '==' when comparing %v", f.Value) } ref, err := fref(f.Path)