google-cloud-firestore 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +2 -1
- data/CHANGELOG.md +43 -0
- data/CONTRIBUTING.md +346 -115
- data/lib/google/cloud/firestore/client.rb +19 -9
- data/lib/google/cloud/firestore/convert.rb +6 -6
- data/lib/google/cloud/firestore/field_path.rb +3 -7
- data/lib/google/cloud/firestore/service.rb +2 -2
- data/lib/google/cloud/firestore/version.rb +1 -1
- data/lib/google/cloud/firestore/watch/inventory.rb +1 -1
- data/lib/google/cloud/firestore.rb +2 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82ce640d6adf49f0b7f73b71c446fb23db7bacd6d9cd8347598b7a4a0c5bc76f
|
4
|
+
data.tar.gz: c81d472495db054a19b0baf395341207087f6de9466e7378ce82f113abbe87c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9955e948ab4d0d6a2dbdd4aa214b1babb3a40f9f3b040fe08a97e91aa8ff7c756282698ea385affc5e8f82e25185ed2fb7d269b192062b0181ed0c3dd984c7f
|
7
|
+
data.tar.gz: 2397f244f4d9a8360d1037538d04aedfa8cea6861f5d64c41672f6ae1201ed530e1d82cb14d1bd03f430c929f00794b6058e490694c3caa314b2697fdd331dd8
|
data/AUTHENTICATION.md
CHANGED
@@ -95,7 +95,8 @@ client = Google::Cloud::Firestore.new
|
|
95
95
|
|
96
96
|
### Configuration
|
97
97
|
|
98
|
-
The **Project ID** and **Credentials JSON** can be configured
|
98
|
+
The **Project ID** and the path to the **Credentials JSON** file can be configured
|
99
|
+
instead of placing them in environment variables or providing them as arguments.
|
99
100
|
|
100
101
|
```ruby
|
101
102
|
require "google/cloud/firestore"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,48 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 2.7.0 (2022-07-02)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Updated minimum Ruby version to 2.6 ([#18446](https://github.com/googleapis/google-cloud-ruby/issues/18446))
|
8
|
+
|
9
|
+
### 2.6.6 / 2022-01-11
|
10
|
+
|
11
|
+
#### Documentation
|
12
|
+
|
13
|
+
* Fix samples/CONTRIBUTING.md
|
14
|
+
* Update version managers list in CONTRIBUTING.md
|
15
|
+
|
16
|
+
### 2.6.5 / 2021-10-25
|
17
|
+
|
18
|
+
#### Documentation
|
19
|
+
|
20
|
+
* Add documentation for quota_project Configuration attribute
|
21
|
+
|
22
|
+
### 2.6.4 / 2021-08-26
|
23
|
+
|
24
|
+
#### Bug Fixes
|
25
|
+
|
26
|
+
* Fix google-cloud-resource-prefix header
|
27
|
+
|
28
|
+
### 2.6.3 / 2021-08-24
|
29
|
+
|
30
|
+
#### Bug Fixes
|
31
|
+
|
32
|
+
* Fix transaction retry behavior
|
33
|
+
|
34
|
+
### 2.6.2 / 2021-07-26
|
35
|
+
|
36
|
+
#### Bug Fixes
|
37
|
+
|
38
|
+
* Update FieldPath#formatted_string to correctly escape non-simple characters
|
39
|
+
|
40
|
+
### 2.6.1 / 2021-07-08
|
41
|
+
|
42
|
+
#### Documentation
|
43
|
+
|
44
|
+
* Update AUTHENTICATION.md in handwritten packages
|
45
|
+
|
3
46
|
### 2.6.0 / 2021-06-15
|
4
47
|
|
5
48
|
#### Features
|
data/CONTRIBUTING.md
CHANGED
@@ -1,187 +1,418 @@
|
|
1
1
|
# Contributing to Google Cloud Firestore
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
Thank you for your interest in making a contribution to google-cloud-ruby. Community contributions are an essential part
|
4
|
+
of open source, and we want to make contributing easy for you. If you have any suggestions for how to improve this
|
5
|
+
guide, please [open an issue](https://github.com/googleapis/google-cloud-ruby/issues) and let us know!
|
6
6
|
|
7
|
-
|
7
|
+
### Code of Conduct
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
Please note that this project is covered by a Contributor Code of Conduct. By participating in this project you agree to
|
10
|
+
abide by its terms. See {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
## Overview
|
13
|
+
|
14
|
+
1. [Open an issue](#open-an-issue)
|
15
|
+
1. [Sign Contributor License Agreement](#sign-contributor-license-agreement)
|
16
|
+
1. [Set up environment](#set-up-environment)
|
17
|
+
1. [Run CI](#run-ci)
|
18
|
+
1. [Make changes](#make-changes)
|
19
|
+
1. [Commit changes](#commit-changes)
|
20
|
+
1. [Run CI again](#run-ci-again)
|
21
|
+
1. [Submit your pull request](#submit-your-pull-request)
|
22
|
+
|
23
|
+
## Open an issue
|
24
|
+
|
25
|
+
Pull requests should generally be directed by an existing issue, otherwise you risk working on something that the
|
26
|
+
maintainers might not be able to accept into the project. Please take a look through [the repository
|
27
|
+
issues](https://github.com/googleapis/google-cloud-ruby/issues?q=is%3Aissue+label%3A%22api%3A+firestore%22), and if you
|
28
|
+
do not see an existing issue for your problem or feature, please open one using one of the provided templates.
|
29
|
+
|
30
|
+
## Sign Contributor License Agreement
|
31
|
+
|
32
|
+
Before we can accept your pull requests you'll need to sign a Contributor License Agreement (CLA):
|
33
|
+
|
34
|
+
- **If you are an individual writing original source code** and **you own the intellectual property**, then you'll need
|
35
|
+
to sign an [individual CLA](https://developers.google.com/open-source/cla/individual).
|
36
|
+
- **If you work for a company that wants to allow you to contribute your work**, then you'll need to sign a [corporate
|
17
37
|
CLA](https://developers.google.com/open-source/cla/corporate).
|
18
38
|
|
19
|
-
You can sign these electronically
|
20
|
-
|
39
|
+
You can sign these electronically. After that, we'll be able to accept your pull requests.
|
40
|
+
|
41
|
+
## Set up environment
|
42
|
+
|
43
|
+
Before you start on a pull request, you should prepare your work environment for development, acceptance testing and the
|
44
|
+
interactive console (optional).
|
21
45
|
|
22
|
-
|
46
|
+
### Local development setup
|
23
47
|
|
24
|
-
|
25
|
-
there is a small amount of setup:
|
48
|
+
To set up your local development environment:
|
26
49
|
|
27
|
-
1. Install
|
28
|
-
|
29
|
-
[
|
30
|
-
[chruby](https://github.com/postmodern/chruby).
|
50
|
+
1. Install a [supported version](google-cloud-firestore.gemspec) (or versions) of Ruby. (You may choose to manage your
|
51
|
+
Ruby and gem installations with [RVM](https://rvm.io/), [rbenv](https://github.com/rbenv/rbenv),
|
52
|
+
[chruby](https://github.com/postmodern/chruby) or a similar tool.)
|
31
53
|
|
32
|
-
|
54
|
+
1. Install [Bundler](http://bundler.io/).
|
33
55
|
|
34
56
|
```sh
|
35
57
|
$ gem install bundler
|
36
58
|
```
|
37
59
|
|
38
|
-
|
60
|
+
1. [Fork](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks) the
|
61
|
+
[google-cloud-ruby](https://github.com/googleapis/google-cloud-ruby) repo, clone your fork, and configure the
|
62
|
+
`upstream`
|
63
|
+
[remote](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-for-a-fork):
|
64
|
+
|
65
|
+
```bash
|
66
|
+
git clone https://github.com/<your-username>/google-cloud-ruby.git
|
67
|
+
cd google-cloud-ruby
|
68
|
+
git remote add upstream git@github.com:googleapis/google-cloud-ruby.git
|
69
|
+
```
|
70
|
+
|
71
|
+
1. If your fork and clone are not brand new, get the latest changes from `upstream`:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
git checkout main
|
75
|
+
git pull upstream main
|
76
|
+
```
|
77
|
+
|
78
|
+
1. Change to the library's sub-directory in the repo:
|
39
79
|
|
40
80
|
```sh
|
41
|
-
$
|
81
|
+
$ cd google-cloud-firestore
|
42
82
|
```
|
43
83
|
|
44
|
-
|
84
|
+
1. Install (or update) the library dependencies:
|
45
85
|
|
46
86
|
```sh
|
47
|
-
$
|
48
|
-
|
87
|
+
$ bundle update
|
88
|
+
```
|
89
|
+
|
90
|
+
1. Create a new topic branch off of the `main` branch:
|
91
|
+
|
92
|
+
```bash
|
93
|
+
git checkout -b <topic-branch>
|
49
94
|
```
|
50
95
|
|
51
|
-
|
96
|
+
### Acceptance tests setup
|
52
97
|
|
53
|
-
|
54
|
-
google-cloud-firestore and its dependencies in IRB. This requires that your
|
55
|
-
developer environment has already been configured by following the steps
|
56
|
-
described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
|
57
|
-
can be created with:
|
98
|
+
To set up your acceptance test credentials:
|
58
99
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
100
|
+
1. If needed, create a Google Cloud project. In the Google Cloud Console, on the project selector page, select or create
|
101
|
+
a project.
|
102
|
+
|
103
|
+
1. Ensure that billing is enabled for your project.
|
104
|
+
|
105
|
+
1. Ensure that the Firestore API is enabled for your project. Note that if you have already enabled the Datastore API
|
106
|
+
for your project, you will need to use a different project for Firestore.
|
107
|
+
|
108
|
+
1. Follow the instructions for [Creating a Service Account](AUTHENTICATION.md#creating-a-service-account) in
|
109
|
+
`AUTHENTICATION.md`, including downloading and securely storing a JSON key file.
|
63
110
|
|
64
|
-
|
111
|
+
1. Set the `GCLOUD_TEST_KEYFILE` environment variable to the path of the JSON key file that you downloaded in the
|
112
|
+
previous step:
|
65
113
|
|
66
|
-
|
67
|
-
|
114
|
+
``` sh
|
115
|
+
$ export GCLOUD_TEST_KEYFILE=/path/to/keyfile.json
|
116
|
+
```
|
117
|
+
|
118
|
+
If you are already using the `GCLOUD_TEST_KEYFILE` environment variable, and wish to test this library with a
|
119
|
+
different key file, you may set the `FIRESTORE_TEST_KEYFILE` environment variable instead:
|
120
|
+
|
121
|
+
``` sh
|
122
|
+
$ export FIRESTORE_TEST_KEYFILE=/path/to/keyfile.json
|
123
|
+
```
|
124
|
+
|
125
|
+
1. Set the `GCLOUD_TEST_PROJECT` environment variable to your Google Cloud project ID:
|
126
|
+
|
127
|
+
``` sh
|
128
|
+
$ export GCLOUD_TEST_PROJECT=my-project-id
|
129
|
+
```
|
68
130
|
|
69
|
-
|
70
|
-
|
131
|
+
If you are already using the `GCLOUD_TEST_PROJECT` environment variable, and wish to test this library with a
|
132
|
+
different project, you may set the `FIRESTORE_TEST_PROJECT` environment variable instead:
|
133
|
+
|
134
|
+
``` sh
|
135
|
+
$ export FIRESTORE_TEST_PROJECT=my-project-id
|
136
|
+
```
|
137
|
+
|
138
|
+
### Interactive console setup (optional)
|
139
|
+
|
140
|
+
To set up your interactive console credentials:
|
141
|
+
|
142
|
+
1. Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of your service account JSON key file (see
|
143
|
+
above):
|
144
|
+
|
145
|
+
``` sh
|
146
|
+
$ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json
|
147
|
+
```
|
148
|
+
|
149
|
+
If you are already using the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, and wish to test this library
|
150
|
+
with a different key file, you may set the `FIRESTORE_CREDENTIALS` environment variable instead:
|
151
|
+
|
152
|
+
``` sh
|
153
|
+
$ export FIRESTORE_CREDENTIALS=/path/to/keyfile.json
|
154
|
+
```
|
155
|
+
|
156
|
+
1. Set the `GOOGLE_CLOUD_PROJECT` environment variable to your Google Cloud project ID:
|
157
|
+
|
158
|
+
``` sh
|
159
|
+
$ export GOOGLE_CLOUD_PROJECT=my-project-id
|
160
|
+
```
|
161
|
+
|
162
|
+
If you are already using the `GOOGLE_CLOUD_PROJECT` environment variable, and wish to test this library with a
|
163
|
+
different project, you may set the `FIRESTORE_PROJECT` environment variable instead:
|
164
|
+
|
165
|
+
``` sh
|
166
|
+
$ export FIRESTORE_PROJECT=my-project-id
|
167
|
+
```
|
168
|
+
|
169
|
+
|
170
|
+
## Run CI
|
171
|
+
|
172
|
+
You are now ready to run local CI checks for the library, which you should do **before** you make any changes. Doing so
|
173
|
+
ensures that everything is OK with your local environment and the latest dependency versions. You don't want any
|
174
|
+
surprises later.
|
175
|
+
|
176
|
+
If you haven't already done so, change to the library's sub-directory in the repo:
|
177
|
+
|
178
|
+
```sh
|
179
|
+
$ cd google-cloud-firestore
|
180
|
+
```
|
181
|
+
|
182
|
+
To run the code style checks, documentation tests, and unit tests together, use the `ci` task:
|
71
183
|
|
72
184
|
``` sh
|
73
|
-
$ cd google-cloud-firestore/
|
74
185
|
$ bundle exec rake ci
|
75
186
|
```
|
76
187
|
|
77
|
-
To run the command above, plus all acceptance tests, use `rake ci:acceptance` or
|
78
|
-
|
188
|
+
To run the command above, plus all acceptance tests, use `rake ci:acceptance` or its handy alias, `rake ci:a`. Keep in
|
189
|
+
mind that the acceptance tests typically take longer than the other CI checks and require authentication credentials.
|
190
|
+
See the [Acceptance tests](#Acceptance-tests) section below for more information.
|
79
191
|
|
80
|
-
|
192
|
+
The Rake tasks aggregated in the commands above can be run individually to streamline your workflow when developing or
|
193
|
+
debugging.
|
81
194
|
|
195
|
+
| CI check | Command |
|
196
|
+
|-----------------------------------------------|------------------ |
|
197
|
+
| [Static code analysis](#Static-code-analysis) | `rake rubocop` |
|
198
|
+
| [Documentation tests](#Documentation-tests) | `rake doctest` |
|
199
|
+
| [Unit tests](#Unit-tests) | `rake test` |
|
200
|
+
| [Acceptance tests](#Acceptance-tests) | `rake acceptance` |
|
82
201
|
|
83
|
-
The
|
84
|
-
including [specs](https://github.com/seattlerb/minitest#specs),
|
85
|
-
[mocks](https://github.com/seattlerb/minitest#mocks) and
|
86
|
-
[minitest-autotest](https://github.com/seattlerb/minitest-autotest).
|
202
|
+
The subsections below describe the individual CI checks.
|
87
203
|
|
88
|
-
|
204
|
+
### Static code analysis
|
89
205
|
|
90
|
-
|
91
|
-
|
92
|
-
|
206
|
+
The project uses [Rubocop](https://github.com/rubocop/rubocop) configured with the shared
|
207
|
+
[googleapis/ruby-style](https://github.com/googleapis/ruby-style) rules to ensure that your code adheres to
|
208
|
+
Google's Ruby style. The style is largely based on [The Ruby Style
|
209
|
+
Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions:
|
210
|
+
|
211
|
+
* Avoid parentheses when possible, including in method definitions.
|
212
|
+
* Use double-quoted strings.
|
213
|
+
|
214
|
+
You can check your code against these rules by running the Rubocop Rake task:
|
215
|
+
|
216
|
+
```sh
|
217
|
+
$ bundle exec rake rubocop
|
93
218
|
```
|
94
219
|
|
95
|
-
|
220
|
+
In the rare case that you need to override the existing Rubocop configuration for this library in order to accommodate
|
221
|
+
your changes, you can do so by updating [.rubocop.yml](.rubocop.yml).
|
96
222
|
|
97
|
-
|
98
|
-
[YARD](https://github.com/lsegal/yard)-based documentation.
|
223
|
+
### Documentation tests
|
99
224
|
|
100
|
-
|
101
|
-
|
102
|
-
[
|
103
|
-
|
225
|
+
When adding a new feature, you should almost always add one or more in-line documentation code examples demonstrating
|
226
|
+
the use of the feature, using [YARD](https://github.com/lsegal/yard)'s
|
227
|
+
[`@example`](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#example) tag. Be sure to write a complete, executable
|
228
|
+
example that includes the library `require` statement and client initialization.
|
104
229
|
|
105
|
-
|
230
|
+
The project uses [yard-doctest](https://github.com/p0deje/yard-doctest) to execute each sample as a unit test:
|
106
231
|
|
107
232
|
``` sh
|
108
|
-
$ cd google-cloud-firestore/
|
109
233
|
$ bundle exec rake doctest
|
110
234
|
```
|
111
235
|
|
112
|
-
If you add, remove or modify documentation examples
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
[`@example`](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#example) tag.
|
117
|
-
If you alter an example's title, you may encounter breaking tests.
|
118
|
-
|
119
|
-
### Firestore Acceptance Tests
|
120
|
-
|
121
|
-
The Firestore acceptance tests interact with the live service API. Follow the
|
122
|
-
instructions in the {file:AUTHENTICATION.md Authentication Guide} for enabling
|
123
|
-
the Firestore API. Occasionally, some API features may not yet be generally
|
124
|
-
available, making it difficult for some contributors to successfully run the
|
125
|
-
entire acceptance test suite. However, please ensure that you do successfully
|
126
|
-
run acceptance tests for any code areas covered by your pull request.
|
236
|
+
If you add, remove or modify documentation examples, you may need to update the setup for the tests. The fixtures, stubs
|
237
|
+
and mocks required to run the tests are located in [support/doctest_helper.rb](support/doctest_helper.rb). Please note
|
238
|
+
that much of the setup is matched to its corresponding example by the title of the `@example` tag. If you alter an
|
239
|
+
example's title, you may encounter broken tests.
|
127
240
|
|
128
|
-
|
129
|
-
|
130
|
-
the KEYFILE location on your system.
|
241
|
+
There are generally no assertions or mock verifications in these tests. They simply check that the examples are
|
242
|
+
syntactically correct and execute against the library source code without error.
|
131
243
|
|
132
|
-
|
133
|
-
used in the tests.
|
244
|
+
### Unit tests
|
134
245
|
|
135
|
-
|
246
|
+
The project uses the [minitest](https://github.com/seattlerb/minitest) library, including
|
247
|
+
[specs](https://github.com/seattlerb/minitest#specs-), [mocks](https://github.com/seattlerb/minitest#mocks-),
|
248
|
+
[minitest-autotest](https://github.com/seattlerb/minitest-autotest), and
|
249
|
+
[minitest-focus](https://github.com/seattlerb/minitest-focus).
|
136
250
|
|
137
|
-
To run the
|
251
|
+
To run the unit tests:
|
138
252
|
|
139
253
|
``` sh
|
140
|
-
$
|
141
|
-
$ bundle exec rake acceptance[\\{my-project-id},\\{/path/to/keyfile.json}]
|
254
|
+
$ bundle exec rake test
|
142
255
|
```
|
143
256
|
|
144
|
-
|
145
|
-
`
|
257
|
+
Although the unit tests are intended to run quickly, during development or debugging you may want to isolate one or more
|
258
|
+
of the tests by placing the `focus` keyword just above the test declaration. (See
|
259
|
+
[minitest-focus](https://github.com/seattlerb/minitest-focus) for details.)
|
146
260
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
261
|
+
#### Conformance tests
|
262
|
+
|
263
|
+
Conformance tests are a subset of the unit test suite. The generated [conformance
|
264
|
+
tests](test/google/cloud/firestore/conformance_test.rb) are based on specifications that are imported from the
|
265
|
+
`firestore` subdirectory in the [googleapis/conformance-tests](https://github.com/googleapis/conformance-tests/) repo to
|
266
|
+
the `conformance` directory. (Currently, the import process involves manually copying the files whenever they are
|
267
|
+
changed in their source repo.) You should never change conformance test specifications in this repo.
|
268
|
+
|
269
|
+
Because the conformance tests are dynamically generated at run time, working with them is more difficult than working
|
270
|
+
with hand-written tests. If you need execute one or more of these tests in isolation, you can do so by placing the
|
271
|
+
`focus` keyword just above one of the calls to `define_method`. This will isolate a subset of the conformance tests. To
|
272
|
+
isolate a single conformance test within the subset, insert a conditional statement into the `test_file.tests.each` loop
|
273
|
+
near the bottom of the `conformance_test.rb` file. In the conditional, call `next` unless the current test `description`
|
274
|
+
matches the test you want to isolate.
|
275
|
+
|
276
|
+
### Acceptance Tests
|
277
|
+
|
278
|
+
The acceptance tests (a.k.a. integration tests) ensure that the library works correctly against the live service API.
|
279
|
+
To configure your Google Cloud project, see [Acceptance tests setup](#acceptance-tests-setup) above.
|
280
|
+
|
281
|
+
**Warning: You may incur charges while running the acceptance tests against your Google Cloud project.**
|
282
|
+
|
283
|
+
Like the unit tests, the acceptance tests are based on the [minitest](https://github.com/seattlerb/minitest) library,
|
284
|
+
including [specs](https://github.com/seattlerb/minitest#specs-) and
|
285
|
+
[minitest-focus](https://github.com/seattlerb/minitest-focus). Mocks are not generally used in acceptance tests.
|
286
|
+
|
287
|
+
Because the acceptance test suite is often time-consuming to run in its entirety, during development or debugging you
|
288
|
+
may want to isolate one or more of the tests by placing the `focus` keyword just above the test declaration. (See
|
289
|
+
[minitest-focus](https://github.com/seattlerb/minitest-focus) for details.)
|
153
290
|
|
154
|
-
|
155
|
-
can use the more specific `FIRESTORE_TEST_PROJECT` and `FIRESTORE_TEST_KEYFILE`
|
156
|
-
environment variables:
|
291
|
+
To run the acceptance tests:
|
157
292
|
|
158
293
|
``` sh
|
159
|
-
$ cd google-cloud-firestore/
|
160
|
-
$ export FIRESTORE_TEST_PROJECT=\\{my-project-id}
|
161
|
-
$ export FIRESTORE_TEST_KEYFILE=\\{/path/to/keyfile.json}
|
162
294
|
$ bundle exec rake acceptance
|
163
295
|
```
|
164
296
|
|
165
|
-
|
297
|
+
Some acceptance tests may depend on API features that are not yet generally available, and will fail unless your project
|
298
|
+
is added to an internal allowlist. There may also be tests that usually pass but fail occasionally due to issues like
|
299
|
+
eventual consistency. However, please ensure that you do successfully run acceptance tests for any code areas covered by
|
300
|
+
your pull request.
|
166
301
|
|
167
|
-
|
168
|
-
largely based on [The Ruby Style
|
169
|
-
Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions based
|
170
|
-
on seattle-style:
|
302
|
+
## Make changes
|
171
303
|
|
172
|
-
|
173
|
-
* Always use double quotes strings. ([Option
|
174
|
-
B](https://github.com/bbatsov/ruby-style-guide#strings))
|
304
|
+
All contributions should include new or updated tests to ensure that the contributed code behaves as expected.
|
175
305
|
|
176
|
-
|
306
|
+
When starting work on a new feature, it often makes sense to begin with a basic acceptance test to ensure that the new
|
307
|
+
feature is present in the live service API and is available to your project. To run your new test exclusively,
|
308
|
+
temporarily add the `focus` keyword just above the test declaration. (See
|
309
|
+
[minitest-focus](https://github.com/seattlerb/minitest-focus) for details.) Also, the acceptance tests have a retry
|
310
|
+
mechanism that can sometimes make it hard to see the correct error when things go wrong. To disable retries while
|
311
|
+
debugging errors, temporarily comment out or remove the `run_one_method` method definition in
|
312
|
+
[acceptance/firestore_helper.rb](acceptance/firestore_helper.rb).
|
313
|
+
|
314
|
+
When you are done developing, be sure to remove any usages of the `focus` keyword from your tests and restore the
|
315
|
+
`run_one_method` method definition if you removed it.
|
316
|
+
|
317
|
+
### Console
|
318
|
+
|
319
|
+
The project includes a Rake task that automatically loads `google-cloud-firestore` and its dependencies in IRB. To
|
320
|
+
configure your Google Cloud project for IRB, see [Interactive console setup](#interactive-console-setup-optional) above.
|
321
|
+
|
322
|
+
**Warning: You may incur charges while using the library with your Google Cloud project.**
|
323
|
+
|
324
|
+
If you haven't already done so, change to the library's sub-directory in the repo:
|
177
325
|
|
178
326
|
```sh
|
179
|
-
$ cd google-cloud-firestore
|
180
|
-
|
327
|
+
$ cd google-cloud-firestore
|
328
|
+
```
|
329
|
+
|
330
|
+
The preloaded IRB console can be used as follows:
|
331
|
+
|
332
|
+
```sh
|
333
|
+
$ bundle exec rake console
|
334
|
+
irb(main):001:0> require "google/cloud/firestore"
|
335
|
+
=> true
|
336
|
+
irb(main):002:0> firestore = Google::Cloud::Firestore.new
|
337
|
+
=> #<Google::Cloud::Firestore::Client:0x00007fea21c8b488 @service=Google::Cloud::Firestore::Service(my-project-id)>
|
338
|
+
irb(main):003:0>
|
339
|
+
```
|
340
|
+
|
341
|
+
Using the console provides an interactive alternative to acceptance testing that may make it easier to explore usage and
|
342
|
+
debug problems.
|
343
|
+
|
344
|
+
## Commit changes
|
345
|
+
|
346
|
+
Commit your changes using [conventional commits](https://www.conventionalcommits.org/), making sure to include the
|
347
|
+
associated GitHub issue number. Below is an example of a `feat` type commit that will result in a semver `minor`
|
348
|
+
release. Notice how it is scoped to the short name of the library, contains a bulleted list of public API changes, and
|
349
|
+
ends with the `closes` GitHub keyword. If this is the only new commit in your branch when you open your pull request,
|
350
|
+
the commit body including the `closes` phrase will be copied to your PR description. If you have multiple commits, you
|
351
|
+
should copy the body of this anchor commit manually to the PR description, so that GitHub will [automatically close the
|
352
|
+
related issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).
|
353
|
+
|
354
|
+
```bash
|
355
|
+
git commit -am "feat(firestore): Add my new feature
|
356
|
+
|
357
|
+
* Add MyClass#my_method
|
358
|
+
|
359
|
+
closes: #123"
|
181
360
|
```
|
182
361
|
|
183
|
-
|
362
|
+
The messages for any subsequent commits you may add do not necessarily need to follow the conventional commits format,
|
363
|
+
as these messages will be manually dropped or added as bullet points to the original message when the PR is squashed and
|
364
|
+
merged.
|
365
|
+
|
366
|
+
## Run CI again
|
367
|
+
|
368
|
+
|
369
|
+
1. If you haven't already done so, change to the library's sub-directory in the repo:
|
370
|
+
|
371
|
+
```sh
|
372
|
+
$ cd google-cloud-firestore
|
373
|
+
```
|
374
|
+
|
375
|
+
1. Rebase your topic branch on the upstream `main` branch:
|
376
|
+
|
377
|
+
```bash
|
378
|
+
git pull --rebase upstream main
|
379
|
+
```
|
380
|
+
|
381
|
+
1. Run the `ci` task:
|
382
|
+
|
383
|
+
``` sh
|
384
|
+
$ bundle exec rake ci
|
385
|
+
```
|
386
|
+
|
387
|
+
1. Run the `acceptance` task:
|
388
|
+
|
389
|
+
``` sh
|
390
|
+
$ bundle exec rake acceptance
|
391
|
+
```
|
392
|
+
|
393
|
+
Ensure that everything is passing in `rake ci` and `rake acceptance`, or at least that `rake ci` is green and you
|
394
|
+
haven't broken anything new in `rake acceptance`, before you open your pull request.
|
395
|
+
|
396
|
+
## Submit your pull request
|
397
|
+
|
398
|
+
1. Rebase your topic branch on the upstream `main` branch:
|
399
|
+
|
400
|
+
```bash
|
401
|
+
git pull --rebase upstream main
|
402
|
+
```
|
403
|
+
|
404
|
+
1. Push your topic branch to your fork:
|
405
|
+
|
406
|
+
```bash
|
407
|
+
git push origin -u
|
408
|
+
```
|
409
|
+
|
410
|
+
1. Open a [pull
|
411
|
+
request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)
|
412
|
+
using the first line of your conventional commit as the title, and with the associated GitHub issue in the
|
413
|
+
description. By convention in this project, the assignee of the pull request will be the maintainer who will merge it
|
414
|
+
once it is approved. If you are a maintainer of the project, typically you should assign the pull request to
|
415
|
+
yourself.
|
416
|
+
|
417
|
+
1. Ensure that all of the GitHub checks are passing.
|
184
418
|
|
185
|
-
Please note that this project is released with a Contributor Code of Conduct. By
|
186
|
-
participating in this project you agree to abide by its terms. See
|
187
|
-
{file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
|
@@ -164,8 +164,7 @@ module Google
|
|
164
164
|
#
|
165
165
|
def col_group collection_id
|
166
166
|
if collection_id.include? "/"
|
167
|
-
raise ArgumentError, "Invalid collection_id: '#{collection_id}', "
|
168
|
-
"must not contain '/'."
|
167
|
+
raise ArgumentError, "Invalid collection_id: '#{collection_id}', must not contain '/'."
|
169
168
|
end
|
170
169
|
|
171
170
|
CollectionGroup.from_collection_id service.documents_path, collection_id, self
|
@@ -628,7 +627,24 @@ module Google
|
|
628
627
|
commit_return = transaction.commit
|
629
628
|
# Conditional return value, depending on truthy commit_response
|
630
629
|
commit_response ? commit_return : transaction_return
|
631
|
-
rescue Google::Cloud::
|
630
|
+
rescue Google::Cloud::AbortedError,
|
631
|
+
Google::Cloud::CanceledError,
|
632
|
+
Google::Cloud::UnknownError,
|
633
|
+
Google::Cloud::DeadlineExceededError,
|
634
|
+
Google::Cloud::InternalError,
|
635
|
+
Google::Cloud::UnauthenticatedError,
|
636
|
+
Google::Cloud::ResourceExhaustedError,
|
637
|
+
Google::Cloud::UnavailableError,
|
638
|
+
Google::Cloud::InvalidArgumentError => e
|
639
|
+
|
640
|
+
if e.instance_of? Google::Cloud::InvalidArgumentError
|
641
|
+
# Return if a previous call was retried but ultimately succeeded
|
642
|
+
return nil if backoff[:current].positive?
|
643
|
+
# The Firestore backend uses "INVALID_ARGUMENT" for transaction IDs that have expired.
|
644
|
+
# While INVALID_ARGUMENT is generally not retryable, we retry this specific case.
|
645
|
+
raise e unless e.message =~ /transaction has expired/
|
646
|
+
end
|
647
|
+
|
632
648
|
# Re-raise if retried more than the max
|
633
649
|
raise e if backoff[:current] > backoff[:max]
|
634
650
|
|
@@ -643,12 +659,6 @@ module Google
|
|
643
659
|
transaction = Transaction.from_client \
|
644
660
|
self, previous_transaction: transaction.transaction_id
|
645
661
|
retry
|
646
|
-
rescue Google::Cloud::InvalidArgumentError => e
|
647
|
-
# Return if a previous call was retried but ultimately succeeded
|
648
|
-
return nil if backoff[:current].positive?
|
649
|
-
|
650
|
-
# Re-raise error.
|
651
|
-
raise e
|
652
662
|
rescue StandardError => e
|
653
663
|
# Rollback transaction when handling unexpected error
|
654
664
|
transaction.rollback rescue nil
|
@@ -50,15 +50,15 @@ module Google
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def fields_to_hash fields, client
|
53
|
-
|
53
|
+
fields.to_h do |key, value|
|
54
54
|
[key.to_sym, value_to_raw(value, client)]
|
55
|
-
end
|
55
|
+
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def hash_to_fields hash
|
59
|
-
|
59
|
+
hash.to_h do |key, value|
|
60
60
|
[String(key), raw_to_value(value)]
|
61
|
-
end
|
61
|
+
end
|
62
62
|
end
|
63
63
|
|
64
64
|
def value_to_raw value, client
|
@@ -304,7 +304,7 @@ module Google
|
|
304
304
|
field_paths = new_data_pairs.map(&:first)
|
305
305
|
|
306
306
|
delete_paths.map!(&:first)
|
307
|
-
root_field_paths_and_values =
|
307
|
+
root_field_paths_and_values = root_field_paths_and_values.to_h
|
308
308
|
|
309
309
|
data, nested_deletes = remove_field_value_from data, :delete
|
310
310
|
raise ArgumentError, "DELETE cannot be nested" if nested_deletes.any?
|
@@ -425,7 +425,7 @@ module Google
|
|
425
425
|
end
|
426
426
|
|
427
427
|
# return new data hash and field path/values hash
|
428
|
-
[
|
428
|
+
[new_pairs.compact.to_h, paths.to_h]
|
429
429
|
end
|
430
430
|
|
431
431
|
def identify_leaf_nodes hash
|
@@ -209,19 +209,15 @@ module Google
|
|
209
209
|
|
210
210
|
protected
|
211
211
|
|
212
|
-
START_FIELD_PATH_CHARS = /\A[a-zA-Z_]/.freeze
|
213
212
|
INVALID_FIELD_PATH_CHARS = %r{[~*/\[\]]}.freeze
|
213
|
+
SIMPLE_FIELD_PATH_CHARS = /\A[_a-zA-Z][_a-zA-Z0-9]*\Z/.freeze
|
214
214
|
|
215
215
|
def escape_field_for_path field
|
216
216
|
field = String field
|
217
217
|
|
218
|
-
if
|
219
|
-
field["."] || field["`"] || field["\\"]
|
220
|
-
escaped_field = field.gsub(/[`\\]/, "`" => "\\\`", "\\" => "\\\\")
|
221
|
-
return "`#{escaped_field}`"
|
222
|
-
end
|
218
|
+
return field if SIMPLE_FIELD_PATH_CHARS.match field
|
223
219
|
|
224
|
-
|
220
|
+
field = field.gsub(/[`\\]/, "`" => "\\`", "\\" => "\\\\")
|
225
221
|
|
226
222
|
"`#{field}`"
|
227
223
|
end
|
@@ -48,7 +48,7 @@ module Google
|
|
48
48
|
config.endpoint = host if host
|
49
49
|
config.lib_name = "gccl"
|
50
50
|
config.lib_version = Google::Cloud::Firestore::VERSION
|
51
|
-
config.metadata = { "google-cloud-resource-prefix": "projects/#{@project}" }
|
51
|
+
config.metadata = { "google-cloud-resource-prefix": "projects/#{@project}/databases/(default)" }
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -189,7 +189,7 @@ module Google
|
|
189
189
|
def document_mask mask
|
190
190
|
return nil if mask.nil?
|
191
191
|
|
192
|
-
mask = Array(mask).map(&:to_s).reject(&:
|
192
|
+
mask = Array(mask).map(&:to_s).reject(&:empty?)
|
193
193
|
return nil if mask.empty?
|
194
194
|
|
195
195
|
Google::Cloud::Firestore::V1::DocumentMask.new field_paths: mask
|
@@ -122,6 +122,8 @@ module Google
|
|
122
122
|
# parameter `keyfile` is considered deprecated, but may also be used.)
|
123
123
|
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
|
124
124
|
# the set of resources and operations that the connection can access.
|
125
|
+
# * `quota_project` - (String) The project ID for a project that can be
|
126
|
+
# used by client libraries for quota and billing purposes.
|
125
127
|
# * `timeout` - (Integer) Default timeout to use in requests.
|
126
128
|
# * `endpoint` - (String) Override of the endpoint host name, or `nil`
|
127
129
|
# to use the default endpoint.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-firestore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-core
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.26.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.26.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '5.
|
89
|
+
version: '5.16'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '5.
|
96
|
+
version: '5.16'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: minitest-autotest
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,14 +265,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
265
265
|
requirements:
|
266
266
|
- - ">="
|
267
267
|
- !ruby/object:Gem::Version
|
268
|
-
version: '2.
|
268
|
+
version: '2.6'
|
269
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
270
|
requirements:
|
271
271
|
- - ">="
|
272
272
|
- !ruby/object:Gem::Version
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
|
-
rubygems_version: 3.
|
275
|
+
rubygems_version: 3.3.14
|
276
276
|
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: API Client library for Google Cloud Firestore API
|