Skip to content

Commit

Permalink
Merge branch 'master' into bc/bulk-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Chen committed Mar 26, 2020
2 parents d94de58 + 708180d commit 6711782
Show file tree
Hide file tree
Showing 230 changed files with 10,332 additions and 15 deletions.
73 changes: 73 additions & 0 deletions dev/conformance/conformance-tests/create-all-transforms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"tests": [
{
"description": "create: all transforms in a single call",
"comment": "A document can be created with any amount of transforms.",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": [\"ArrayUnion\", 1, 2, 3], \"d\": [\"ArrayRemove\", 4, 5, 6]}",
"request": {
"database": "projects/projectID/databases/(default)",
"writes": [
{
"update": {
"name": "projects/projectID/databases/(default)/documents/C/d",
"fields": {
"a": {
"integerValue": "1"
}
}
},
"currentDocument": {
"exists": false
}
},
{
"transform": {
"document": "projects/projectID/databases/(default)/documents/C/d",
"fieldTransforms": [
{
"fieldPath": "b",
"setToServerValue": "REQUEST_TIME"
},
{
"fieldPath": "c",
"appendMissingElements": {
"values": [
{
"integerValue": "1"
},
{
"integerValue": "2"
},
{
"integerValue": "3"
}
]
}
},
{
"fieldPath": "d",
"removeAllFromArray": {
"values": [
{
"integerValue": "4"
},
{
"integerValue": "5"
},
{
"integerValue": "6"
}
]
}
}
]
}
}
]
}
}
}
]
}
69 changes: 69 additions & 0 deletions dev/conformance/conformance-tests/create-arrayremove-multi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"tests": [
{
"description": "create: multiple ArrayRemove fields",
"comment": "A document can have more than one ArrayRemove field.\nSince all the ArrayRemove fields are removed, the only field in the update is \"a\".",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3], \"c\": {\"d\": [\"ArrayRemove\", 4, 5, 6]}}",
"request": {
"database": "projects/projectID/databases/(default)",
"writes": [
{
"update": {
"name": "projects/projectID/databases/(default)/documents/C/d",
"fields": {
"a": {
"integerValue": "1"
}
}
},
"currentDocument": {
"exists": false
}
},
{
"transform": {
"document": "projects/projectID/databases/(default)/documents/C/d",
"fieldTransforms": [
{
"fieldPath": "b",
"removeAllFromArray": {
"values": [
{
"integerValue": "1"
},
{
"integerValue": "2"
},
{
"integerValue": "3"
}
]
}
},
{
"fieldPath": "c.d",
"removeAllFromArray": {
"values": [
{
"integerValue": "4"
},
{
"integerValue": "5"
},
{
"integerValue": "6"
}
]
}
}
]
}
}
]
}
}
}
]
}
53 changes: 53 additions & 0 deletions dev/conformance/conformance-tests/create-arrayremove-nested.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"tests": [
{
"description": "create: nested ArrayRemove field",
"comment": "An ArrayRemove value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayRemove\", 1, 2, 3]}}",
"request": {
"database": "projects/projectID/databases/(default)",
"writes": [
{
"update": {
"name": "projects/projectID/databases/(default)/documents/C/d",
"fields": {
"a": {
"integerValue": "1"
}
}
},
"currentDocument": {
"exists": false
}
},
{
"transform": {
"document": "projects/projectID/databases/(default)/documents/C/d",
"fieldTransforms": [
{
"fieldPath": "b.c",
"removeAllFromArray": {
"values": [
{
"integerValue": "1"
},
{
"integerValue": "2"
},
{
"integerValue": "3"
}
]
}
}
]
}
}
]
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"tests": [
{
"description": "create: ArrayRemove cannot be anywhere inside an array value",
"comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayRemove. Firestore transforms don't support array indexing.",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": [1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]}",
"isError": true
}
}
]
}
13 changes: 13 additions & 0 deletions dev/conformance/conformance-tests/create-arrayremove-noarray.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"tests": [
{
"description": "create: ArrayRemove cannot be in an array value",
"comment": "ArrayRemove must be the value of a field. Firestore\ntransforms don't support array indexing.",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}",
"isError": true
}
}
]
}
13 changes: 13 additions & 0 deletions dev/conformance/conformance-tests/create-arrayremove-with-st.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"tests": [
{
"description": "create: The ServerTimestamp sentinel cannot be in an ArrayUnion",
"comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": [\"ArrayRemove\", 1, \"ServerTimestamp\", 3]}",
"isError": true
}
}
]
}
53 changes: 53 additions & 0 deletions dev/conformance/conformance-tests/create-arrayremove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"tests": [
{
"description": "create: ArrayRemove with data",
"comment": "A key with ArrayRemove is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3]}",
"request": {
"database": "projects/projectID/databases/(default)",
"writes": [
{
"update": {
"name": "projects/projectID/databases/(default)/documents/C/d",
"fields": {
"a": {
"integerValue": "1"
}
}
},
"currentDocument": {
"exists": false
}
},
{
"transform": {
"document": "projects/projectID/databases/(default)/documents/C/d",
"fieldTransforms": [
{
"fieldPath": "b",
"removeAllFromArray": {
"values": [
{
"integerValue": "1"
},
{
"integerValue": "2"
},
{
"integerValue": "3"
}
]
}
}
]
}
}
]
}
}
}
]
}
69 changes: 69 additions & 0 deletions dev/conformance/conformance-tests/create-arrayunion-multi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"tests": [
{
"description": "create: multiple ArrayUnion fields",
"comment": "A document can have more than one ArrayUnion field.\nSince all the ArrayUnion fields are removed, the only field in the update is \"a\".",
"create": {
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
"jsonData": "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3], \"c\": {\"d\": [\"ArrayUnion\", 4, 5, 6]}}",
"request": {
"database": "projects/projectID/databases/(default)",
"writes": [
{
"update": {
"name": "projects/projectID/databases/(default)/documents/C/d",
"fields": {
"a": {
"integerValue": "1"
}
}
},
"currentDocument": {
"exists": false
}
},
{
"transform": {
"document": "projects/projectID/databases/(default)/documents/C/d",
"fieldTransforms": [
{
"fieldPath": "b",
"appendMissingElements": {
"values": [
{
"integerValue": "1"
},
{
"integerValue": "2"
},
{
"integerValue": "3"
}
]
}
},
{
"fieldPath": "c.d",
"appendMissingElements": {
"values": [
{
"integerValue": "4"
},
{
"integerValue": "5"
},
{
"integerValue": "6"
}
]
}
}
]
}
}
]
}
}
}
]
}
Loading

0 comments on commit 6711782

Please sign in to comment.