Commit Graph
83 Commits
Author SHA1 Message Date
Gil c866936c7d Upgrade the emulator we use for integration testing to 1.4.6 (#3038)
* Bump to cloud-firestore-emulator 1.4.6
* Re-enable transform-related integration tests against the emulator
* Re-enable collection-group query integration tests
* Re-enable most transaction-related tests
2019-05-20 21:42:58 -07:00
Brian Chen afe63ccff5 Add clearPersistence() to Firestore client(#2993) 2019-05-17 11:29:20 -07:00
Brian Chen 6c6ef3b904 Throw error in subsequent function calls after the client is shutdown (#2978) 2019-05-09 17:07:05 -07:00
Gil 6fc90d34ef Fix sanitizer builds (#2940)
* Make GrpcConnection safe to use with thread sanitizer

One additional lock acquisition per connection attempt isn't going to
kill us.

* Make tests pass with tsan and ubsan
2019-05-07 09:16:03 -07:00
Gil 9c1035bfe3 Run Firestore integration tests against the emulator (#2936)
* Run Firestore integration tests against the emulator

* Ignore emulator-related files

* Add a script to run the Firestore emulator

* Blacklist all transformation-related tests
2019-05-03 18:15:33 -07:00
Gil 547ed27027 Add support for running Firestore integration tests against the emulator (#2922) 2019-05-03 07:55:57 -07:00
Michael Lehenbauer 754d5c07d4 Expose Collection Group queries. (#2786) 2019-04-09 20:50:58 -07:00
Gil 8ef6cf80be Fix use-after-free in DocumentReference::AddSnapshotListener (#2686) 2019-03-29 20:40:48 -07:00
Michael Lehenbauer 22cdb796be Fix a couple expected error messages in tests to match recent code changes. (#2685) 2019-03-29 20:00:33 -07:00
Gil ba332be794 Port FSTAsyncQueryListener to C++ (#2620)
* Test that shows a leak.

* Add EventListener to match Android.

* Use AsyncEventListener in FSTQueryListenerTests

* Remove FSTAsyncQueryListener

* Use EventListener throughout
2019-03-26 11:54:03 -07:00
Gil 9c95d61304 Update project and fix warnings (#2531)
* Update Firestore project to Xcode 10.1 defaults

* Fix NSUInteger in format strings warning

* Fix implicit conversion warning in FSTLevelDB

* Fix BOOL/bool mismatch

* Fix erroneous comparison

This failure shows up on 32-bit targets. I have no idea why this
succeeds on 64-bit targets.

* Fix incorrect type inference with explicit cast

clang is inferring the type of the key in these maps is `NSString *` and
then complaining that `FIRFieldValue *` doesn't match that type, despite
the underlying method taking `NSDictionary<id, id>`. Explicitly casting
to `id` prevents the warning.

* Remove reliance on representation in FSTFieldValue tests

On *some* platforms [NSNumber numberWithChar:1] ends up with a "c"
(signed char) objcType, but apparently on 32-bit platforms this ends up
as "i" (signed int). Rather than relying on this working properly just
test that [NSNumber numberWithBool:] does the right thing.

* Fix field_value_test on 32-bit targets

When sizeof(void*) is 4 the test failed :-(.

* Rephrase testWritesWithLargeNumbersFail in terms of fixed size types

The prior definition only worked on LP64. Switching to LLONG_MAX would
have also fixed this, but Firestore's data model is independent of C's
data model, so rewriting this in terms of fixed size types more closely
models what's actually an invalid value.

* Fix implicit retain self warnings
2019-03-12 15:58:52 -07:00
Michael Lehenbauer bd0b8e9449 Collection Group Query Internals (#2378)
Includes the new index and all internals for collection group queries, but the public API will not be exposed until backend support is ready.
2019-03-08 13:37:00 -08:00
Sebastian Schmidt 657f53a9b8 Adding FieldValue.increment() (#2075) 2019-03-06 14:51:30 -08:00
rsgowman ca38562d3f Fix build for non-clang compilers (#2391) 2019-03-01 13:51:59 -05:00
rsgowman 0f32878009 Forbid queries endAt an uncommitted server timestamp. (#2382)
Without this, it still fails, but:
a) not until serializing the query, and
b) the error is an internal error, and
c) the error message is quite cryptic and has nothing to do with the problem.

Port of https://github.com/firebase/firebase-android-sdk/pull/138
2019-02-13 12:12:42 -05:00
Michael Lehenbauer a43709f18e Port flaky test fix from web. (#2332)
Port flaky test fix from web.

Port of https://github.com/firebase/firebase-js-sdk/pull/1511
2019-02-01 15:02:12 -08:00
Gil 2ac7c2f2ea Verify large write batches support (#2321)
* Reorder tests to match Android
* Add missing NS_ASSUME_NONNULL_BEGIN
* Add missing [self awaitExpectations]
* Port can write very large batches from Android
2019-01-28 17:21:49 -08:00
Michael Lehenbauer 5c67653de3 Change timestampsInSnapshots default to true and deprecate the setting. (#2251) 2019-01-11 13:47:13 -08:00
Paul Beusterien 7c53489e03 Travis to Xcode 10.1 and clang-format to 8.0.0 (tags/google/stable/2018-08-24) (#2222)
* Travis to Xcode 10.1
* Update to clang-format 8
* Update clang-format homebrew link
* Work around space in filename style.sh issue
2019-01-02 09:27:31 -08:00
zxu 2b30c54ed3 fix a typo in integration test (#2131)
* fix a typo in integration test

* relax else condition to catch all abnormal cases
2018-11-29 14:02:44 -05:00
Konstantin Varlamov e0d797515c C++: eliminate FSTDispatchQueue and replace it with AsyncQueue (#2062)
* replace all references to `FSTDispatchQueue` and `FSTTimerID` with their C++ equivalents;
* remove `FSTDispatchQueue` class and related tests;
* in method argument names, replace `workerDispatchQueue` with just `workerQueue`, more similar to other platforms;
* move `Executor` and derived classes out of `internal` namespace.
2018-11-18 17:49:32 -05:00
Sebastian Schmidt 5bc4cc55a6 Remove Held Write Acks (#2029)
* Drop acknowledged mutations in schema migration (#1818)

Drop acknowledged mutations in schema migration as part of removing held write acks.

Port of firebase/firebase-js-sdk#1149

* Change removeMutationBatch to remove a single batch (#1955)

* Update Firestore Generated Protos

*  Adding UnknownDocument and hasCommittedMutations (#1971)

* Removing held write batch handling from LocalStore (#1997)

* View changes for held write acks (#2004)

* Held Write Acks Unit Test Fixes (#2008)

* Held Write Ack Removal Spec Tests (#2018)

* Fix integration test
2018-11-01 09:44:30 -07:00
zxu b86911573f Clean up test. The issue has already been fixed and we are now running integration test with actual server instead of hexa. (#2007) 2018-10-25 17:10:44 -04:00
Sebastian Schmidt 08dede03ba Don't drop empty object during merge (#1851) 2018-09-19 14:43:08 -07:00
Michael Lehenbauer 3827391c46 Offline get() improvements. (#1783)
[Port of https://github.com/firebase/firebase-js-sdk/pull/1197]

1. Changed MAX_WATCH_STREAM_FAILURES to 1 per conversation with @wilhuff and
   @jdimond.
2. Fixed a "race" where when a get() triggered a watch stream error, we'd
   restart the stream, then get() would remove its listener, and so we had no
   listener left once the watch stream was "opened". Without a listen to send
   we'd be stuck in Offline state (even though we should be Unknown whenever
   we have no listens to send), resulting in the next get() returning data
   from cache without even attempting to reach the backend.
2018-09-06 07:59:51 -07:00
Michael Lehenbauer b88f95c44f Reformat using 'clang-format version 7.0.0 (tags/google/stable/2018-04-24)' (#1681)
This is the version of clang-format that travis is currently using.
2018-08-13 14:18:02 -07:00
Michael Lehenbauer da1c5346dd Fix for #1632.
get with source='cache' was not properly handling cached deleted documents.
2018-08-06 14:25:09 -07:00
Michael Lehenbauer 25f8691970 Expose array transforms and array contains queries. (#1514)
Also remove test code that was combining multiple array contains
queries since those were disallowed in
https://github.com/firebase/firebase-ios-sdk/commit/0ec836f9ca71b27fa54a11ae9e07e60b8c5cc002
2018-07-10 16:58:56 -07:00
Konstantin Varlamov 0f0a1dab2d Eliminate unnecessary DocumentKey->FSTDocumentKey conversions (#1507) 2018-07-10 16:08:18 -04:00
Konstantin Varlamov ff95ffc61b In FSTLocalDocumentsView, search for all batches affecting a set of keys in one go (#1505)
This uses the newly-added allMutationBatchesAffectingDocumentKeys to find/deserialize all such batches in one go and then reuse the batches while processing a set of keys.
2018-07-10 13:59:25 -04:00
Sebastian Schmidt d13a51abac Allowing field deletes using merge fields (#1389) 2018-06-07 13:57:01 -07:00
Michael Lehenbauer 0ec836f9ca b/79432277: Limit Queries to only a single array-contains clause. (#1286) 2018-05-16 17:05:33 -07:00
Michael Lehenbauer 8409f21830 Backport array contains / transform improvements from Web. (#1242) 2018-05-08 15:33:10 -07:00
Michael Lehenbauer e91de9258a b/78539022: Fix test at risk of range violation errors depending on time-of-day. (#1213)
micros could underflow or overflow if the test was run at the wrong time... Replaced with hardcoded timestamps as I don't think making it time-dependent gains us interesting additional coverage.
2018-05-02 14:54:51 -07:00
Sebastian Schmidt 542d81ac68 Adding mergeFields support (#1141) 2018-05-02 11:10:19 -07:00
Michael Lehenbauer e4384c3e80 Array Contains Queries (not added to public headers yet). (#1138) 2018-04-23 10:03:55 -07:00
Michael Lehenbauer 7dca635039 Move array transforms to internal header pending backend support. (#1139) 2018-04-20 14:48:59 -07:00
zxu 5d3c76f543 fix integration test (#1134) 2018-04-18 15:59:08 -04:00
rsgowman a5b3185ed3 Add GetOptions for controlling offline get behaviour (#655)
Add option to allow the user to control where DocumentReference.getDocument() and CollectionReference.getDocuments() fetches from. By default, it fetches from the server (if possible) and falls back to the local cache. It's now possible to alternatively fetch from the local cache only, or to fetch from the server only (though in the server only case, latency compensation is still enabled).
2018-04-18 10:30:37 -04:00
Michael Lehenbauer e36cc9610b Integration tests, changelog, and minor fixes for array transforms. (#1108) 2018-04-17 15:55:29 -07:00
Gil a25d054874 Replace the SnapshotOptions object with the behavior enum. (#1109)
Instead of calling

  `get(field, SnapshotOptions.serverTimestampBehavior(.estimate))`

call

  `get(field, serverTimestampBehavior: .estimate)`
2018-04-16 13:50:11 -07:00
Gil 4de2d80e43 Replace QueryListenOptions with simple booleans (#1106)
* Replace `QueryListenOptions` with simple booleans

Instead of calling

  addSnapshotListener(
      options:QueryListenOptions.includeQueryMetadataChanges()
                                .includeDocumentMetadataChanges())

call

  addSnapshotListener(includeMetadataChanges:true)

Also change `QuerySnapshot.documentChanges()` into a method which
optionally takes `includeMetadataChanges:true`. By default even when
listening to a query with `inlcudeMetadataChanges:true` metadata-only
document changes are suppressed because they're confusing.

* Revert QuerySnapshot.documentChanges back to a property

Add usage.
2018-04-15 16:56:43 -07:00
Gil 5368c9e22f Replace the SetOptions object with a simple boolean. (#1098)
Instead of calling

  `setData(["a": "b"], options: SetOptions.merge())`

call

  `setData(["a": "b"], merge: true)`
2018-04-15 13:06:06 -07:00
Gil 33b12f6c70 Replace DocumentListenOptions with a simple boolean. (#1099)
* Replace `DocumentListenOptions` with a simple boolean.

Instead of calling

  `addSnapshotListener(options: DocumentListenOptions.includeMetadataChanges(true))`

call

  `addSnapshotListener(includeMetadataChanges:true)`

* Style
2018-04-14 17:19:06 -07:00
Michael Lehenbauer c2d4d3a9cf Small cleanup to UserDataConverter / FieldValue sentinel code to make adding more FieldValue sentinels easier. (#1077)
Port of https://github.com/firebase/firebase-js-sdk/commit/b14678002bf6e8cc9ebd7561efbafe29315ceb8e and https://github.com/firebase/firebase-js-sdk/commit/b14678002bf6e8cc9ebd7561efbafe29315ceb8e.
2018-04-12 13:50:02 -07:00
Konstantin Varlamov a17740e914 Add a flag to control whether DocumentSnapshots return Dates or Timestamps for timestamp fields (#831)
* add a new property `timestampsInSnapshotsEnabled` to `FirestoreSettings`, `false` by default;
* add a verbose warning message urging users to opt into the new behavior;
* set `timestampsInSnapshotsEnabled` to true in the integration tests to reduce the verbose console
spam during the test run and make sure the flag won't break anything once it's flipped.
2018-03-30 14:50:15 -04:00
zxu 9e815620e9 grand PR to port the remaining paths (FieldPath and ResourcePath). (#865)
* naively remove FSTPath import and source/test files.

* port FieldPath, part I

* port FieldPath, part II

* port ResourcePath, part I

* port ResourcePath, part II

* the grand commit to fix build errors

* use testutil:: helper instead of those from FSTHelpers

* fix test and lint

* use c_str in errmsg directly

* fix

* fix

* make code clean

* fix integration test I missed

* fix to avoid naming collision in preprocessor

* address changes

* address changes

* address changes

* fix: fieldMask are actually shared with different context.

* address changes

* address changes
2018-03-14 08:57:31 -04:00
Konstantin Varlamov 50f9df9240 Accept FIRTimestamp where NSDate is currently accepted as a parameter (#823) 2018-02-21 15:36:23 -05:00
Konstantin Varlamov 14ea068f5f Make FSTTimestamp into a public Firestore class (#698)
- FSTTimestamp is now FIRTimestamp, under Firestore/Source/{Public,API}. This is a temporary solution; eventually, FIRTimestamp is supposed to live somewhere under Firebase;
- move most internal Timestamp methods to the public header (the only exception is ISOString).
2018-02-20 17:33:57 -05:00
Michael Lehenbauer 81ee594e32 DispatchQueue delayed callback improvements + testing (#784)
Basically a port of https://github.com/firebase/firebase-js-sdk/commit/a1e346ff93c6cbcc0a1b3b33f0fbc3a7b66e7e12 and https://github.com/firebase/firebase-js-sdk/commit/fce4168309f42aa038125f39818fbf654b65b05f

* Introduces a DelayedCallback helper class in FSTDispatchQueue to encapsulate delayed callback logic.
* Adds cancellation support.
* Updates the idle timer in FSTStream to use new cancellation support.
* Adds a FSTTimerId enum for identifying delayed operations on the queue and uses it to identify our existing backoff and idle timers.
* Added containsDelayedCallback: and runDelayedCallbacksUntil: methods to FSTDispatchQueue which can be used from tests to check for the presence of a callback or to schedule them to run early.
* Removes FSTTestDispatchQueue and changes idle tests to use new test methods.
2018-02-15 16:17:44 -08:00