Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion google/cloud/spanner_v1/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ def reload(self):
self._encryption_config = response.encryption_config
self._encryption_info = response.encryption_info
self._default_leader = response.default_leader
self._database_dialect = response.database_dialect
# Only update if the data is specific to avoid losing specificity.
if response.database_dialect != DatabaseDialect.DATABASE_DIALECT_UNSPECIFIED:

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.

Will there be such a situation where backend returns UNSPECIFIED dialect?
AFAIK, the default dialect is GOOGLE_SQL. Correct me if I am missing something

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is an issue when working with the emulator. It is returning DATABASE_DIALECT_UNSPECIFIED which is overriding the dialect that this object already had. This shouldn't be an issue in production.

self._database_dialect = response.database_dialect
self._enable_drop_protection = response.enable_drop_protection
self._reconciling = response.reconciling

Expand Down
9 changes: 9 additions & 0 deletions tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def not_google_standard_sql(database_dialect):
)


@pytest.fixture(scope="session")
def not_postgres_emulator(database_dialect):
if database_dialect == DatabaseDialect.POSTGRESQL and _helpers.USE_EMULATOR:
pytest.skip(
f"{_helpers.DATABASE_DIALECT_ENVVAR} set to POSTGRESQL and {_helpers.USE_EMULATOR_ENVVAR} set in "
"environment."
)


@pytest.fixture(scope="session")
def database_dialect():
return (
Expand Down
1 change: 0 additions & 1 deletion tests/system/test_instance_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def test_create_instance(


def test_create_instance_with_processing_units(
not_emulator,
if_create_instance,
spanner_client,
instance_config,
Expand Down
8 changes: 5 additions & 3 deletions tests/system/test_session_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,9 @@ def unit_of_work(transaction):
assert span.parent.span_id == span_list[-1].context.span_id


def test_execute_partitioned_dml(sessions_database, database_dialect):
def test_execute_partitioned_dml(
not_postgres_emulator, sessions_database, database_dialect
):
# [START spanner_test_dml_partioned_dml_update]
sd = _sample_data
param_types = spanner_v1.param_types
Expand Down Expand Up @@ -2420,7 +2422,7 @@ def test_execute_sql_w_json_bindings(


def test_execute_sql_w_jsonb_bindings(
not_emulator, not_google_standard_sql, sessions_database, database_dialect
not_google_standard_sql, sessions_database, database_dialect
):
_bind_test_helper(
sessions_database,
Expand All @@ -2432,7 +2434,7 @@ def test_execute_sql_w_jsonb_bindings(


def test_execute_sql_w_oid_bindings(
not_emulator, not_google_standard_sql, sessions_database, database_dialect
not_google_standard_sql, sessions_database, database_dialect
):
_bind_test_helper(
sessions_database,
Expand Down