-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Add support for new Firestore types #14800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
* Add RegexValue class. * Add to/from proto logic. * Add comparison logic and unit tests. * Add serializer unit test. * Add Codable support, Improve Swift API, Add integration test. * Add more unit tests and integration tests. Also fixed a bug found by unit tests. * Add 6 other types' public API. * rename `.m` to `.mm` to stay consistent. * More unit tests. * WIP: Add the FieldValue methods for building new types. * Add the Swift API and the Obj-C Unit tests. * Add UserDataReader support for new types. * Add missing `extern`. * Add UserDataWriter support for types. Int32 is still missing. * UserDataWriter support for int32. * Update TypeOrder usages with new types. * Add comparison logic for more types. * Add Int32Value comparison logic. * Add SerializerTests for more types. * Use snake case. * Add more unit tests. * Fix bug and add integration test. * Add more integration tests. * Add more integration tests. * Add more integration and unit tests. * Expose public `isEqual` for new types and add tests for it. * Add cross-type order test. * Add Codable support along with integration tests for them. * Remove named parameter for Int32Value and BsonObjectId. * clang-format. * Use `uint8_t` for BsonBinaryData's subtype. * Add `description` for new types. * Reuse type check logic for new types. * Use uint8_t for BsonBinaryData. * Adds tests for FIRFieldValue static c'tors of new types. * Add a few missing tests. * Update tests to check listeners, src=cache, src=server. * Remove FieldValue factory methods.
* Add RegexValue class. * Add to/from proto logic. * Add comparison logic and unit tests. * Add serializer unit test. * Add Codable support, Improve Swift API, Add integration test. * Add more unit tests and integration tests. Also fixed a bug found by unit tests. * Add 6 other types' public API. * rename `.m` to `.mm` to stay consistent. * More unit tests. * WIP: Add the FieldValue methods for building new types. * Add the Swift API and the Obj-C Unit tests. * Add UserDataReader support for new types. * Add missing `extern`. * Add UserDataWriter support for types. Int32 is still missing. * UserDataWriter support for int32. * Update TypeOrder usages with new types. * Add comparison logic for more types. * Add Int32Value comparison logic. * Add SerializerTests for more types. * Use snake case. * Add more unit tests. * Fix bug and add integration test. * Add more integration tests. * Add more integration tests. * Add more integration and unit tests. * Expose public `isEqual` for new types and add tests for it. * Add cross-type order test. * Add Codable support along with integration tests for them. * Remove named parameter for Int32Value and BsonObjectId. * clang-format. * Use `uint8_t` for BsonBinaryData's subtype. * Add `description` for new types. * Reuse type check logic for new types. * Use uint8_t for BsonBinaryData. * Adds tests for FIRFieldValue static c'tors of new types. * Add a few missing tests. * Update tests to check listeners, src=cache, src=server. * Implement indexing for bson types. * Add test for offline write and read from cache. * WIP: Adding more unit tests and integration tests. * Add IndexAllTypesTogether test. * Properly handle empty segments in ref. * Add ComputesLowerBound test. * Add ComputesUpperBound test. * Add IndexValueWriterTest. * Add bson types to index_value_writer_test.cc. * Add CSI tests for bson types. * Check ordered results for queries served from the index. * Add TODO for failing tests. * Address comments. * Improve doc ordering in the new leveldb_local_store_test tests.
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback. |
Generated by 🚫 Danger |
TODO (ehsann): Update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, these build failures are expected. I think it's acceptable to merge with the spm-binary workflow failing, and I'll fix right after. Another option is to build a zip off of this branch but that's only worth doing when the PR is final. Either way works–– we just need to update the SPM FST binary to include the new sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. It seems that the rollout is going to take longer. So, we need to keep the PR open for a bit. I'll ping you before we merge the PR.
|
||
#include "Firestore/Source/Public/FirebaseFirestore/FIRBsonBinaryData.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove NS_ASSUME_NONNULL_BEGIN
and NS_ASSUME_NONNULL_END
from .m or .mm files. These macros only have an effect when used in header files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
self = [super init]; | ||
if (self) { | ||
_subtype = subtype; | ||
_data = data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@property(atomic, copy, readonly) NSData *data;
When initializing a property with the copy attribute, the property setter that does the copy doesn't run when accessing the ivar with the _ prefix. So the copy needs to be manual here:
_data = data; | |
_data = [data copy]; |
Good article: https://furbo.org/2012/05/04/arc-and-copy/
Since this and the other types are immutable and don't re-set the properties after initialization, the copy
isn't doing anything. I'm okay with removing it or leaving it as-is as documentation of the intended ownership strategy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh! TIL! keeping the copy
. Done
* @param subtype An 8-bit unsigned integer denoting the subtype of the data. | ||
* @param data The binary data. | ||
*/ | ||
- (instancetype)initWithSubtype:(uint8_t)subtype data:(nonnull NSData *)data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think the warning has to do with this line. The class interface is wrapped with NS_ASSUME_NONNULL_BEGIN
which auto assumes every param is nonnull already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, the nonnull could be removed as NS_ASSUME_NONNULL_BEGIN is adding it for you.
The issue is that
- (BOOL)isEqual:(id)object;
should actually be - (BOOL)isEqual:(nullable id)object;
. Added suggestion below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the nonnulls here are duplicates since the class assumes nonnull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
- (instancetype)initWithSubtype:(uint8_t)subtype data:(nonnull NSData *)data; | ||
|
||
/** Returns true if the given object is equal to this, and false otherwise. */ | ||
- (BOOL)isEqual:(id)object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- (BOOL)isEqual:(id)object; | |
- (BOOL)isEqual:(nullable id)object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
/** Returns true if the given object is equal to this, and false otherwise. */ | ||
- (BOOL)isEqual:(nullable id)object; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hide default initializer inherited from NSObject
superclass.
- (instancetype)init NS_UNAVAILABLE; | |
|
||
/** Returns true if the given object is equal to this, and false otherwise. */ | ||
- (BOOL)isEqual:(nullable id)object; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hide default initializer inherited from NSObject
superclass.
- (instancetype)init NS_UNAVAILABLE; | |
__attribute__((objc_subclassing_restricted)) | ||
@interface FIRMaxKey : NSObject | ||
|
||
/** Returns the only instance of MaxKey. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit – consistent doc comment for Max and Min keys
/** Returns the only instance of MaxKey. */ | |
/** The shared singleton `MaxKey` instance. */ |
__attribute__((objc_subclassing_restricted)) | ||
@interface FIRMinKey : NSObject | ||
|
||
/** The only instance of MinKey. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** The only instance of MinKey. */ | |
/** The shared singleton `MinKey` instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This file looks to use only Objective-C, so the extension can just be .m
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This file looks to use only Objective-C, so the extension can just be .m
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This file looks to use only Objective-C, so the extension can just be .m
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This file looks to use only Objective-C, so the extension can just be .m
/** Returns true if the given object is equal to this, and false otherwise. */ | ||
- (BOOL)isEqual:(nullable id)object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, why was the isEqual
API added for all of these new types?
@@ -0,0 +1,15 @@ | |||
// Copyright 2025 Google LLC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note on these redirect headers– they were added to preserve existing header imports when we reorganized the Firestore modules so that the top-most FirebaseFirestore
module was actually a Swift module. Unless these headers need to be imported in C++ clients, we probably could remove them in favor of customers importing them with the module style import of FirebaseFirestore.
Adds support for MinKey, MaxKey, RegexValue, Int32Value, BsonObjectId, BsonTimestamp, and BsonBinaryData.