Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the BSONRegex class to represent BSON Regular Expression containers for Firestore, along with corresponding unit and system tests. The new class is integrated into the package's public API and supports pattern validation, option flag normalization (including conversion from Python re flags), serialization, and comparison operations. There are no review comments, and I have no feedback to provide.
67d6ca3 to
b93150c
Compare
b93150c to
ed7f12b
Compare
ed7f12b to
ce477c3
Compare
ce477c3 to
c3d09f8
Compare
c3d09f8 to
c488151
Compare
c488151 to
4f302c4
Compare
daniel-sanche
left a comment
There was a problem hiding this comment.
My main request is for test cases with invalid options
| "int32_val": BSONInt32(42), | ||
| "binary_val_sub128": BSONBinary(b"world", subtype=128), | ||
| "timestamp_val": BSONTimestamp(1700000000, 1), | ||
| "regex_val": BSONRegex("^hello.*$", options="i"), |
There was a problem hiding this comment.
Can you add a test case with invalid options? Like including l?
We should make sure the library handles it well, and gives a clear error message
| re.VERBOSE: "x", | ||
| } | ||
|
|
||
| def __init__(self, pattern: str, options: Union[str, re.RegexFlag, int] = ""): |
There was a problem hiding this comment.
I'd recommend dropping int and re.RegexFlag, since we only support a subset of the flags. It might give users the wrong expectations. And other languages only support strings here
I don't have a deep understanding of this though, so you you feel confident about this, we can keep it
4f302c4 to
60347d0
Compare
60347d0 to
10464ca
Compare
Adds the
BSONRegexdata type to support BSON regular expression field serialization in Google Cloud Firestore according to the official Firestore BSON specification.BSONRegexContainer Class: Introducesgoogle.cloud.firestore_v1.bson.BSONRegexto encapsulate regex patterns (pattern: str) and option flags (options: str | re.RegexFlag | int).reflag integers (re.IGNORECASE | re.MULTILINE) into sorted, unique BSON option flag strings (e.g.,"im")._to_map_value()convertingBSONRegexinto the reserved{"__regex__": {"pattern": pattern, "options": options}}wire map representation.google.cloud.firestore_v1andgoogle.cloud.firestore).Fixes: b/562163604