Skip to content

Commit 4cec9b1

Browse files
author
Michael Lehenbauer
committed
Include '/documents' for root document paths.
1 parent 01bbbc2 commit 4cec9b1

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

packages/firestore/src/remote/serializer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,6 @@ export class JsonProtoSerializer {
340340
}
341341

342342
toQueryPath(path: ResourcePath): string {
343-
if (path.length === 0) {
344-
// If the path is empty, the backend requires we leave off the /documents
345-
// at the end.
346-
return this.encodedDatabaseId;
347-
}
348343
return this.toResourceName(this.databaseId, path);
349344
}
350345

packages/firestore/test/unit/remote/node/serializer.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ describe('Serializer', () => {
911911
const result = s.toTarget(wrapQueryData(q));
912912
expect(result).to.deep.equal({
913913
query: {
914-
parent: 'projects/p/databases/d',
914+
parent: 'projects/p/databases/d/documents',
915915
structuredQuery: {
916916
from: [{ collectionId: 'messages' }],
917917
orderBy: [
@@ -954,7 +954,7 @@ describe('Serializer', () => {
954954
const result = s.toTarget(wrapQueryData(q));
955955
const expected = {
956956
query: {
957-
parent: 'projects/p/databases/d',
957+
parent: 'projects/p/databases/d/documents',
958958
structuredQuery: {
959959
from: [{ collectionId: 'docs' }],
960960
where: {
@@ -992,7 +992,7 @@ describe('Serializer', () => {
992992
const result = s.toTarget(wrapQueryData(q));
993993
const expected = {
994994
query: {
995-
parent: 'projects/p/databases/d',
995+
parent: 'projects/p/databases/d/documents',
996996
structuredQuery: {
997997
from: [{ collectionId: 'docs' }],
998998
where: {
@@ -1093,7 +1093,7 @@ describe('Serializer', () => {
10931093
const result = s.toTarget(wrapQueryData(q));
10941094
const expected = {
10951095
query: {
1096-
parent: 'projects/p/databases/d',
1096+
parent: 'projects/p/databases/d/documents',
10971097
structuredQuery: {
10981098
from: [{ collectionId: 'docs' }],
10991099
orderBy: [
@@ -1119,7 +1119,7 @@ describe('Serializer', () => {
11191119
const result = s.toTarget(wrapQueryData(q));
11201120
const expected = {
11211121
query: {
1122-
parent: 'projects/p/databases/d',
1122+
parent: 'projects/p/databases/d/documents',
11231123
structuredQuery: {
11241124
from: [{ collectionId: 'docs' }],
11251125
orderBy: [
@@ -1154,7 +1154,7 @@ describe('Serializer', () => {
11541154
const result = s.toTarget(wrapQueryData(q));
11551155
const expected = {
11561156
query: {
1157-
parent: 'projects/p/databases/d',
1157+
parent: 'projects/p/databases/d/documents',
11581158
structuredQuery: {
11591159
from: [{ collectionId: 'docs' }],
11601160
orderBy: [
@@ -1197,7 +1197,7 @@ describe('Serializer', () => {
11971197
);
11981198
const expected = {
11991199
query: {
1200-
parent: 'projects/p/databases/d',
1200+
parent: 'projects/p/databases/d/documents',
12011201
structuredQuery: {
12021202
from: [{ collectionId: 'docs' }],
12031203
orderBy: [

0 commit comments

Comments
 (0)