Skip to content

fix(firestore): Refactor the parameters for timestamp expressions and fix bug for timeGranularity lowercase#9750

Merged
yvonnep165 merged 13 commits intomainfrom
yvonne/refactor-timestamp-parameters
Mar 26, 2026
Merged

fix(firestore): Refactor the parameters for timestamp expressions and fix bug for timeGranularity lowercase#9750
yvonnep165 merged 13 commits intomainfrom
yvonne/refactor-timestamp-parameters

Conversation

@yvonnep165
Copy link
Copy Markdown
Contributor

@yvonnep165 yvonnep165 commented Mar 24, 2026

Changes on top of #9728:

  • Create new type TimeUnit and refactor the timestampAdd, timestampSubtract and timestampDiff expressions to use this value
  • Change the type TimeGranularity to include type TimeUnit directly and change the camelCase value to lowercase
  • Remove the toLowerCase() usage in timestampTruncate and timestampExtract
  • Change the parameter isoweek used in the integration test

Question: Currently I put "patch" for this change in changeset, not sure whether I should keep it as "patch" or change it to "minor"?

@yvonnep165 yvonnep165 requested review from dlarocque and milaGGL March 24, 2026 19:42
@yvonnep165 yvonnep165 requested review from a team as code owners March 24, 2026 19:42
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: f6f1116

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
firebase Patch
@firebase/firestore Patch
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the handling of time unit parameters within Firestore's timestamp expressions. By introducing a dedicated TimeUnit type and updating existing TimeGranularity definitions to be consistent with lowercase values, the changes enhance type safety, reduce potential runtime errors from case mismatches, and improve the overall robustness and clarity of the API for time-based operations.

Highlights

  • New TimeUnit Type Introduced: A new TimeUnit type has been created to explicitly define time units ('microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'), improving type safety and clarity for timestamp operations.
  • Refactored Timestamp Functions: The timestampAdd, timestampSubtract, and timestampDiff expressions have been refactored to utilize the new TimeUnit type, streamlining their parameter definitions.
  • Updated TimeGranularity Definition: The TimeGranularity type now directly incorporates TimeUnit and has been updated to use lowercase values for 'isoweek' and 'isoyear' for consistency.
  • Removed toLowerCase() Calls: Redundant toLowerCase() calls in timestampTruncate and timestampExtract functions have been removed, as TimeGranularity values are now consistently defined in lowercase.
  • Integration Test Update: An integration test for timestampTruncate was updated to reflect the new lowercase 'isoweek' value.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The 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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

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

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 refactors timestamp expression parameters by introducing a new TimeUnit type to simplify function signatures for timestampAdd, timestampDiff, and timestampSubtract. It also standardizes TimeGranularity values to lowercase (e.g., isoWeek to isoweek). The changes include updates to API definitions, documentation, and relevant test cases to reflect these type and casing adjustments.

@yvonnep165 yvonnep165 requested review from hsubox76 and removed request for hsubox76 March 25, 2026 14:57
Base automatically changed from yvonne/timestamp-expressions to main March 25, 2026 16:19
@yvonnep165 yvonnep165 merged commit dd10ed7 into main Mar 26, 2026
49 of 50 checks passed
@yvonnep165 yvonnep165 deleted the yvonne/refactor-timestamp-parameters branch March 26, 2026 17:34
@google-oss-bot google-oss-bot mentioned this pull request Apr 8, 2026
@firebase firebase locked and limited conversation to collaborators Apr 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants