Skip to content

Navigation Menu

Sign in
Sign up
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

fix(spanner): restore implicit database_dialect reload in sync client - #1537

Merged
sinhasubham merged 1 commit into
main from
sync_fix
Mar 30, 2026
Merged

fix(spanner): restore implicit database_dialect reload in sync client #1537
sinhasubham merged 1 commit into
main from
sync_fix

Conversation

@sinhasubham

@sinhasubham sinhasubham commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Problem
Following the introduction of AsyncIO support via CrossSync, code generation for the synchronous client caused a regression in Database.database_dialect.

Previously, if the property was accessed and returned DATABASE_DIALECT_UNSPECIFIED, the client would implicitly make a blocking self.reload() to retrieve the dialect from the server. This was lost during the shift to CrossSync as properties cannot be asynchronous in the _async source of truth.

Solution
Restore the lazy-loading reload behavior via an environment check:

_async/database.py: Added if not CrossSync.is_async: guard directly into the database_dialect getter. This makes it un-reachable code in the async runtime (where blocking properties or un-awaited coroutines are frowned upon).
database.py: The generator strips the CrossSync context into a standard synchronous self.reload() call, successfully maintaining strict backwards compatibility for all existing synchronous libraries.

gemini-code-assist[bot] reacted with eyes emoji
@product-auto-label product-auto-label Bot added size: xs Pull request size is extra small. api: spanner Issues related to the googleapis/python-spanner API. labels Mar 30, 2026

@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 updates the database_dialect property in both the sync and async Database classes to automatically call reload() if the dialect is unspecified. A review comment identifies a potential for excessive API calls if the reload fails to update the dialect and suggests implementing a flag to ensure the reload is only attempted once.

Comment thread google/cloud/spanner_v1/_async/database.py

@bhatt4982 bhatt4982 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.

LGTM...

sinhasubham merged commit 81f9451 into main Mar 30, 2026
24 checks passed
sinhasubham deleted the sync_fix branch March 30, 2026 12:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments
@bhatt4982 bhatt4982 bhatt4982 approved these changes
Reviewers whose approvals may not affect merge requirements

Labels

api: spanner Issues related to the googleapis/python-spanner API. size: xs Pull request size is extra small.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /