Skip to content
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

feat(firestore): Added multiple firestore database support #719

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KSokhal
Copy link

@KSokhal KSokhal commented Sep 15, 2023

#718 Added support for multiple Firestore databases within a single app

@google-cla
Copy link

google-cla bot commented Sep 15, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@lahirumaramba lahirumaramba changed the title Added multiple firestore support feat(firestore): Added multiple firestore database support Jan 24, 2024
Copy link

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

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

The usage of the firestore client LGTM overall, but I don't have enough context on the rest of the project to give a full approval

self._client = firestore.Client(credentials=credentials, project=project)
def __init__(self, credentials, project, database_id=None):
if database_id:
self._client = firestore.Client(credentials=credentials, project=project, database=database_id)

Choose a reason for hiding this comment

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

note: the database parameter is only upported in firestore v2.12.0+, but this repo supports v2.9.1.

It's probably ok, but we might want to double-check that it fails gracefully when used with an older version

Copy link
Author

Choose a reason for hiding this comment

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

Wasn't sure the best way to do this but I included a version check if attempting to use older that v2.12.0

Copy link
Member

Choose a reason for hiding this comment

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

I think we can update the firestore version to the latest in the next release so this check probably won't be necessary (we don't check the version in other SDKs). I understand this PR has been sitting here for a while so I will first merge this and then remove the version check in a follow up PR :)

@@ -93,8 +93,10 @@ def _get_initialized_app(app):



def get_app_service(app, name, initializer):
def get_app_service(app, options, name, initializer):

Choose a reason for hiding this comment

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

I see this is a private module, but adding a new positional argument into the middle of the list seems dangerous. Can this be an optional kwarg?

Copy link
Author

Choose a reason for hiding this comment

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

Done

self._client = firestore.Client(credentials=credentials, project=project, database=database_id)
else:
self._client = firestore.Client(credentials=credentials, project=project)

Choose a reason for hiding this comment

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

we should add some tests for this new functionality

Copy link
Author

Choose a reason for hiding this comment

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

I added a test to cover when an explicit database id is given

@lahirumaramba lahirumaramba requested review from lahirumaramba and removed request for tom-andersen and wu-hui January 25, 2024 16:57
Check firestore ver is > 2.12.0 is using database id
Added test for explicit database id
@dr-nyt
Copy link

dr-nyt commented May 12, 2024

Any ETA on when this will be pushed? Urgently need this feature.

self._client = firestore.Client(credentials=credentials, project=project)
def __init__(self, credentials, project, database_id=None):
if database_id:
self._client = firestore.Client(credentials=credentials, project=project, database=database_id)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can update the firestore version to the latest in the next release so this check probably won't be necessary (we don't check the version in other SDKs). I understand this PR has been sitting here for a while so I will first merge this and then remove the version check in a follow up PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants