Skip to content

Commit fdd73ca

Browse files
author
Brian Chen
authored
Send raw values when using WebChannel (#2228)
1 parent fa0e63d commit fdd73ca

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/firestore/src/remote/serializer.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,20 @@ export class JsonProtoSerializer {
160160
}
161161

162162
/**
163-
* Returns a value for a number (or undefined) that's appropriate to put into
163+
* Returns a value for a number (or null) that's appropriate to put into
164164
* a google.protobuf.Int32Value proto.
165165
* DO NOT USE THIS FOR ANYTHING ELSE.
166166
* This method cheats. It's typed as returning "number" because that's what
167167
* our generated proto interfaces say Int32Value must be. But GRPC actually
168168
* expects a { value: <number> } struct.
169169
*/
170-
private toInt32Value(val: number | null): number | undefined {
171-
if (!typeUtils.isNullOrUndefined(val)) {
170+
private toInt32Value(val: number | null): number | null {
171+
if (this.options.useProto3Json || typeUtils.isNullOrUndefined(val)) {
172+
return val;
173+
} else {
174+
// ProtobufJS requires that we wrap Int32Values.
172175
// eslint-disable-next-line @typescript-eslint/no-explicit-any, We need to match generated Proto types.
173176
return { value: val } as any;
174-
} else {
175-
return undefined;
176177
}
177178
}
178179

@@ -1043,7 +1044,7 @@ export class JsonProtoSerializer {
10431044
}
10441045

10451046
const limit = this.toInt32Value(query.limit);
1046-
if (limit !== undefined) {
1047+
if (limit !== null) {
10471048
result.structuredQuery!.limit = limit;
10481049
}
10491050

0 commit comments

Comments
 (0)