Skip to content

feat(firestore): add BSONRegex support - #18394

Open
ohmayr wants to merge 1 commit into
bson-pr1e-timestampfrom
bson-pr1f-regex
Open

ohmayr wants to merge 1 commit into
bson-pr1e-timestampfrom
bson-pr1f-regex

Conversation

@ohmayr

@ohmayr ohmayr commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Adds the BSONRegex data type to support BSON regular expression field serialization in Google Cloud Firestore according to the official Firestore BSON specification.

  • BSONRegex Container Class: Introduces google.cloud.firestore_v1.bson.BSONRegex to encapsulate regex patterns (pattern: str) and option flags (options: str | re.RegexFlag | int).
  • Flag Normalization: Automatically normalizes Python re flag integers (re.IGNORECASE | re.MULTILINE) into sorted, unique BSON option flag strings (e.g., "im").
  • Wire Serialization: Implements _to_map_value() converting BSONRegex into the reserved {"__regex__": {"pattern": pattern, "options": options}} wire map representation.
  • SDK Surface Export: Exported on top-level package namespaces (google.cloud.firestore_v1 and google.cloud.firestore).

Fixes: b/562163604

@ohmayr
ohmayr added this pull request to stack #18386 September 16, 2026 08:44

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ohmayr
ohmayr marked this pull request as ready for review September 16, 2026 18:50
@ohmayr
ohmayr requested review from a team as code owners September 16, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant