Commit Graph
93 Commits
Author SHA1 Message Date
zxu a441190635 Implement Firestore DatabaseInfo and port both Database{Id,Info} C++ to the iOS code (#738)
* implement Firestore DatabaseInfo in C++

* temporary stash changes; blocking on the massive renaming of .m to .mm

* add database_info_test to project

* finish port DatabaseId and fix style, modular fixing DatabaseInfo

* port DatabaseInfo

* remove FSTDatabase{ID,Info} and their tests from project

* fix unit test

* use namespace alias

* use namespace alias, leftover

* address more changes

* refactoring to use raw pointer instead of value for property

* address changes

* remove self->

* fix style

* remove the name suffix Alloc

* fix a bug
2018-02-06 13:51:11 -05:00
Morgan Chen 7422f62182 fix null block execution crash 2018-02-02 11:31:32 -08:00
Gil 515625c47f Remove predecessorKey,Object,Document, etc (#735)
This is dead code.

I think it was probably useful in the RTDB because of the way it notified of changes, but we give changes with indexes in Firestore so I think we don't need it.
2018-02-01 07:55:49 -08:00
Gil 729b8d176c Move all Firestore Objective-C to Objective-C++ (#734)
* Move all Firestore files to Objective-C++
* Update project file references
* Don't use module imports from Objective-C++
* Use extern "C" for C-accessible globals
* Work around more stringent type checking in Objective-C++
  * NSMutableDictionary ivars aren't implicitly casted to NSDictionary
  * FSTMaybeDocument callback can't be passed a function that accepts
    FSTDocument
  * NSComparisonResult can't be multiplied by -1 without casting
* Add a #include <inttypes.h> where needed
* Avoid using C++ keywords as variables
* Remove #if __cplusplus guards
2018-01-31 11:23:55 -08:00
Greg Soltis 3cbdbf2652 Schema migrations for LevelDB (#728)
* Implement schema versions

* Style fixes

* newlines, copyrights, assumptions

* Fix nullability

* Raw ptr -> shared_ptr

* kVersionTableGlobal -> kVersionGlobalTable

* Drop utils, move into static methods

* Drop extra include

* Add a few more comments

* Move version constant into migrations file

* formatting?

* Fix comment
2018-01-30 14:36:22 -08:00
Paul Beusterien cceeec3e7b travis: check for copyright in sources (#717) 2018-01-27 16:00:28 -08:00
Michael Lehenbauer 4d7c973369 Fix b/72502745: OnlineState changes cause limbo document crash. (#470) (#714)
[PORT OF https://github.com/firebase/firebase-js-sdk/pull/470]

Context: I made a previous change to raise isFromCache=true events when the
client goes offline. As part of this change I added an assert for
"OnlineState should not affect limbo documents", which it turns out was not
valid because:
* When we go offline, we set the view to non-current and call
	View.applyChanges().
* View.applyChanges() calls applyTargetChange() even though there's no target
	change and it recalculates limbo documents.
* When the view is not current, we consider no documents to be in limbo.
* Therefore all limbo documents are removed and so applyChanges() ends up
	returning unexpected LimboDocumentChanges.

Fix: I've modified the View logic so that we don't recalculate limbo documents
(and generate LimboDocumentChanges) when the View is not current, so now my
assert holds and there should be less spurious removal / re-adding of limbo
documents.
2018-01-27 15:03:05 -08:00
zxu af6976a907 normalize and port the rest of Firebase/Port code (#713)
* normalize bits
* normalize ordered_code
2018-01-27 14:53:27 -08:00
zxu 7226b4adf3 port TargetIdGenerator to iOS (#709)
* port TargetIdGenerator to iOS

* fix style

* move pointer property to instance variable

* TriggerTravis
2018-01-25 18:39:46 -05:00
zxu 5fdda3fa83 normalize string_util (#708)
* refactoring string_util
* port string_util to iOS
2018-01-25 13:03:07 -05:00
Gil 5bfcb3b8cf Cleanup imports and isEqual (#685)
* Fix headers

* Fix isEqual verbosity

* Fix isEqual for nullable properties

* Fix nullability on FSTTestDocSnapshot
2018-01-21 21:14:58 -08:00
Gil 39d8252300 Port comparison to C++ (#678)
This reimplements our comparison functions as C++ Comparators and then provides compatibility shims for interoperating with existing Objective-C usage.

A few specialized comparators aren't suitable for porting but only have a single usage (e.g. CompareBytes for comparing NSData * instances). In these cases I've moved them into the caller.

* Use int32_t for typeof(ID) in FSTDocumentReference

* Migrate callers of FSTComparison.h to Objective-C++

* Port comparison to C++

* Migrate usages of FSTComparison.h to C++ equivalents

* Remove FSTComparison
2018-01-19 12:27:11 -08:00
Greg Soltis 70d401d483 Listen sequence numbers (#675)
* Generate and save sequence numbers for listens

* Add documentation

* Fix include path

* Fix unavailable comment

* Review feedback
2018-01-17 12:23:45 -08:00
Michael Lehenbauer da506b86bc Fix issue @morganchen12 discovered where we weren't properly creating FIRQueryDocumentSnapshot instances. (#662) 2018-01-12 15:54:42 -08:00
Michael Lehenbauer a8f7e20050 Remove over-aggressive closeWithFinalState: delegate assert. (#656)
Fixes #596. closeWithFinalState: asserted delegate != nil, but that is not true if when
startWithdelegate: was called we entered backoff (performBackoffWithDelegate:)
and so self.delegate did not get assigned yet.

We could rework the code to make the assertion hold, but per offline
discussion this assert doesn't represent an invariant that we care about
maintaining and so I'm just removing it.
2018-01-11 17:13:00 -08:00
rsgowman 1bafdb4ce5 Fix FSTLocalDocumentsView to allow multiple mutations while offline (#644)
* Fix FSTLocalDocumentsView to allow multiple mutations while offline.

Previously, only the last mutation would actually be visible.
2018-01-11 08:50:49 -08:00
Michael Lehenbauer dc0b29e9cf Run style.sh (#636)
Run style.sh (w/ clang-format version 6)
2018-01-10 09:28:44 -08:00
Sebastian Schmidt ed6c6f9fea Fixing potential race in ServerTimestamp tests 2018-01-05 10:34:38 -08:00
Greg Soltis 275b4e5a76 Log pending writes when we disable the network (#604)
* Log pending writes when we disable the network

* Fix formatting

* Formatting
2018-01-02 14:03:07 -08:00
Gil 8c2777b245 Fix races in lazy initialization of the client in FIRFirestore (#579)
* Fix races in lazy initialization of the client in FIRFirestore

Note that lazy initialization is required because we allow the user to
assign to settings after instantiation before any methods are used.

Also bring method naming closer to the android port.
2017-12-20 11:15:42 -08:00
Michael Lehenbauer faca4ea11b Rename all the onlineStateChanged methods to applyChangedOnlineState. (#574) 2017-12-19 16:05:20 -08:00
zxu 9ddf3637ac Firestore isEqual() on Public Types (#569)
* add bone code for new isEqual and unit test for old isEqual

*   add bone code for `FIRCollectionReference`, `FIRDocumentSnapshot`, `FIRFieldValue`, `FIRQuerySnapshot`, `FIRSnapshotMetadata`;
*   change inconsistenciness of `FIRFieldPath.isEqual` implementation;
*   add unit test (and file) for `FIRDocumentReferenceTest.m`, `FIRFieldPathTest.m`, `FIRQueryTests.testEquals`; `FIRGeoPoint` already has test and Blob is internal type.

* Implement isEqual for FIRCollectionReference

adding the working code and unit test.

* implement isEqual for FIRSnapshotMetadata

* Implement isEqual for FIRDocumentSnapshot

* Implement isEqual for FIRQuerySnapshot

* (un)implement `isEqual` for `FIRFieldValue`

Since `FIRFieldValue` both types are singleton, we do not need override `isEqual`. Add test to test the default `NSObject` `isEqual` works just fine.

* fix style with `scripts/style.sh`

* Implement hash for those with overridden isEqual without hash yet.

* refactor to use test helper functions -- FSTTestFirestore, FSTTestPath, FSTTestDocKey

* refactor using test helper `FSTTestDocSnapshot`, `FSTTestFieldPath`, `FSTTestQuery`, `FSTTestDoc`

* refactoring to use test helper method `FSTTestQuerySnapshot`,

* remove unneccessary nil-check, check isKindOfClass instead of isEqual

* refactoring: adding `FSTAPIHelpers.{h,m}`, `FSTTest{Collection,Document}Ref`,  better naming and style fix

* a file forgot in last commit

* mainly clean up import and some minor refactoring

* fix style via style.sh

* minor style fix

* add pragma ignored -Wnonnull
2017-12-19 13:47:04 -05:00
Greg Soltis 52c7329f2a Expose network management (#566)
* Expose network management in public API

* Clean up a few more references to the internal access of network management

* Move test

* Update comments

* Swap _Nullable for nullable

* Fix comment

* Add tests, including swift

* Styling
2017-12-18 18:50:08 -08:00
Michael Lehenbauer 8db0eb618d Test cleanup: Adds a helper for waiting for FSTVoidErrorBlock callbacks.
* Add helper for waiting for FSTVoidErrorBlock callbacks.
* Remove errorEventHandler from FSTEventAccumulator.h too.
* Add synchronous enableNetwork / disableNetwork helpers.
* Workaround for batch writes test flakiness.
2017-12-18 14:21:11 -08:00
Michael Lehenbauer d4de7a6e86 b/68276665: Raise isFromCache=true events when offline (#567)
* Plumbs FSTOnlineState changes through to views.
* View sets this.current to false on FSTOnlineStateFailed, triggering
	isFromCache=true events. It will automatically be returned to true
	once the listen is reestablished and we get a new CURRENT message.
* Updated tests (and added one new one) to verify behavior.
* Unifies setOnlineStateToUnknown, setOnlineStateToHealthy, and
	updateAndBroadcastOnlineState into a single updateOnlineState
	method.
* Split disableNetwork into (public) disableNetwork and
	(private) disableNetworkWithTargetOnlineState methods..
* Some miscellaneous comment cleanup.

* Add missing comment per CR feedback.
2017-12-15 14:56:03 -08:00
Sebastian Schmidt 98e08bc0b8 Merge pull request #565 from firebase/mrschmidt-missingmethods
Adding missing SnapshotOptions method
2017-12-15 05:35:23 +08:00
Sebastian Schmidt 08bd327bbf Adding Swift build test 2017-12-14 11:04:45 +08:00
Sebastian Schmidt 2dd7324bd5 Adding missing SnapshotOptions method 2017-12-13 17:30:11 +08:00
zxu 8f85bd199d Fix new warnings w.r.t. predicate query change (#555) 2017-12-12 08:35:08 -08:00
Sebastian Schmidt cf4bda440f Adding missing word in comment 2017-12-12 09:38:32 +08:00
Sebastian Schmidt 601c13b0fb Using 100 as line length for comments 2017-12-12 08:20:59 +08:00
Sebastian Schmidt e006383cda Merge 2017-12-12 08:15:20 +08:00
Sebastian Schmidt e019a9461a Merge branch 'firestore-api-changes' into mrschmidt-timestamps 2017-12-12 08:03:59 +08:00
Sebastian Schmidt fe4783838e Addressing comments 2017-12-12 07:59:44 +08:00
Sebastian Schmidt 5b1ca51e72 Addressing comments 2017-12-12 07:11:39 +08:00
Sebastian Schmidt 64066c643d Adding Generics 2017-12-12 07:02:26 +08:00
zxu 54ba423c87 Revisit commit method in FIRWriteBatch (#541)
* revisit FIRWriteBatch commit

*   make commitWithCompletion completion nullable;
*   add commit;
*   add unit test;
*   add swift build test for commit;
*   update CHANGELOG.
2017-12-11 15:37:01 -05:00
Sebastian Schmidt fe4ed518d7 Comment fix 2017-12-10 23:55:03 -08:00
Sebastian Schmidt 23ee2aaf46 Clang format 2017-12-10 23:51:45 -08:00
Sebastian Schmidt e23236bd38 Running scripts/style.sh 2017-12-10 23:07:53 -08:00
Sebastian Schmidt bc179ea4ea Making DocumentSnapshot nullable 2017-12-10 14:40:22 -08:00
Sebastian Schmidt 84e7f27a3f Adding default option 2017-12-08 14:02:23 -08:00
zxu 440014eb37 make FIRDocumentListenOptions.includeMetadataChanges private (#540)
*   make FIRDocumentListenOptions.includeMetadataChanges private

as discussed in Firestore API discussion, the name clashes creates confusion. Android SDK already not exposing the property; here change iOS SDK to match it.

*   update CHANGELOG
2017-12-08 09:22:56 -05:00
Sebastian Schmidt bf48b0abc1 Method renames 2017-12-07 19:54:08 -08:00
Sebastian Schmidt 904a141217 Addressing all review comments 2017-12-07 16:03:40 -08:00
Gil c7bade7aba Merge pull request #542 from firebase/master
sync firestore-api-changes with master
2017-12-07 14:14:03 -08:00
zxu 5da88e4b9b Implement NSPredicate-based query (#531)
*   implement queryFilteredUsingPredicate in FIRQuery;
*   add unit test and integration test for queryFilteredUsingPredicate;
*   project change of adding the FIRQueryTests.m file;
*   refactoring queryFilteredUsingPredicate to split logic into two helpers;
2017-12-07 15:36:15 -05:00
Paul Beusterien 293c6e252e Add FirebaseFirestore.h to fix Firebase module in source build (#539) 2017-12-07 06:19:59 -08:00
zxu 4daf75d372 Merge pull request #514 from firebase/zxu/logoffline
Warn user if we raise with empty while not online
2017-12-07 09:05:02 -05:00
zxu123 125cdc78c6 refactoring the condition when to warn offline 2017-12-06 16:16:22 -05:00