Skip to content

Send raw values when using WebChannel #2228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/firestore/src/remote/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,20 @@ export class JsonProtoSerializer {
}

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

Expand Down Expand Up @@ -1043,7 +1044,7 @@ export class JsonProtoSerializer {
}

const limit = this.toInt32Value(query.limit);
if (limit !== undefined) {
if (limit !== null) {
result.structuredQuery!.limit = limit;
}

Expand Down