Skip to content

Commit

Permalink
fix(firestore): Allow using != with nil (googleapis#11112)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhshkh authored Nov 11, 2024
1 parent f072178 commit 5b59819
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions firestore/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion firestore/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5b59819

Please sign in to comment.