Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -471,20 +471,20 @@ async def read(
)
request_options = _merge_request_options(request_options, client_context)

if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)

if self._read_only:
request_options.transaction_tag = None
if (
directed_read_options is None
and database._directed_read_options is not None
):
directed_read_options = database._directed_read_options
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
if self._read_only:
request_options.transaction_tag = None
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
elif not self._read_only and self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.

if (
self._read_only
and directed_read_options is None
and database._directed_read_options is not None
):
directed_read_options = database._directed_read_options

read_request = ReadRequest(
session=session.name,
Expand Down Expand Up @@ -665,20 +665,20 @@ async def execute_sql(
)
request_options = _merge_request_options(request_options, client_context)

if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)

if self._read_only:
request_options.transaction_tag = None
if (
directed_read_options is None
and database._directed_read_options is not None
):
directed_read_options = database._directed_read_options
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
if self._read_only:
request_options.transaction_tag = None
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
elif not self._read_only and self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.

if (
self._read_only
and directed_read_options is None
and database._directed_read_options is not None
):
directed_read_options = database._directed_read_options

execute_sql_request = _make_execute_sql_request(
session_name=session.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,13 @@ async def commit(
)
request_options = _merge_request_options(request_options, client_context)

if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)

if self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag

# Request tags are not supported for commit requests.
request_options.request_tag = None
if request_options is not None:
if self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
# Request tags are not supported for commit requests.
request_options.request_tag = None
elif self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)

common_commit_request_args = {
"session": session.name,
Expand Down Expand Up @@ -526,11 +523,10 @@ async def execute_update(
)
request_options = _merge_request_options(request_options, client_context)

if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
elif self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.

trace_attributes = {
"db.statement": dml,
Expand Down Expand Up @@ -686,11 +682,10 @@ async def batch_update(
)
request_options = _merge_request_options(request_options, client_context)

if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
elif self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.

trace_attributes = {
# Get just the queries from the DML statement batch
Expand Down
52 changes: 26 additions & 26 deletions packages/google-cloud-spanner/google/cloud/spanner_v1/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,19 @@ def read(
database._instance._client._client_context, self._client_context
)
request_options = _merge_request_options(request_options, client_context)
if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)
if self._read_only:
request_options.transaction_tag = None
if (
directed_read_options is None
and database._directed_read_options is not None
):
directed_read_options = database._directed_read_options
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
if self._read_only:
request_options.transaction_tag = None
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
elif not self._read_only and self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
if (
self._read_only
and directed_read_options is None
and (database._directed_read_options is not None)
):
directed_read_options = database._directed_read_options
read_request = ReadRequest(
session=session.name,
table=table,
Expand Down Expand Up @@ -603,19 +603,19 @@ def execute_sql(
database._instance._client._client_context, self._client_context
)
request_options = _merge_request_options(request_options, client_context)
if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)
if self._read_only:
request_options.transaction_tag = None
if (
directed_read_options is None
and database._directed_read_options is not None
):
directed_read_options = database._directed_read_options
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
if self._read_only:
request_options.transaction_tag = None
elif self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
elif not self._read_only and self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
if (
self._read_only
and directed_read_options is None
and (database._directed_read_options is not None)
):
directed_read_options = database._directed_read_options
execute_sql_request = _make_execute_sql_request(
session_name=session.name,
sql=sql,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,12 @@ def commit(
database._instance._client._client_context, self._client_context
)
request_options = _merge_request_options(request_options, client_context)
if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)
if self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
request_options.request_tag = None
if request_options is not None:
if self.transaction_tag is not None:
request_options.transaction_tag = self.transaction_tag
request_options.request_tag = None
elif self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
common_commit_request_args = {
"session": session.name,
"transaction_id": self._transaction_id,
Expand Down Expand Up @@ -438,11 +437,10 @@ def execute_update(
database._instance._client._client_context, self._client_context
)
request_options = _merge_request_options(request_options, client_context)
if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
elif self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
trace_attributes = {"db.statement": dml, "request_options": request_options}
is_inline_begin = False
if self._transaction_id is None:
Expand Down Expand Up @@ -577,11 +575,10 @@ def batch_update(
database._instance._client._client_context, self._client_context
)
request_options = _merge_request_options(request_options, client_context)
if request_options is None:
request_options = RequestOptions()
elif type(request_options) is dict:
request_options = RequestOptions(request_options)
request_options.transaction_tag = self.transaction_tag
if request_options is not None:
request_options.transaction_tag = self.transaction_tag
Comment thread
olavloite marked this conversation as resolved.
elif self.transaction_tag is not None:
request_options = RequestOptions(transaction_tag=self.transaction_tag)
Comment thread
olavloite marked this conversation as resolved.
Comment thread
olavloite marked this conversation as resolved.
trace_attributes = {
"db.statement": ";".join([statement.sql for statement in parsed]),
"request_options": request_options,
Expand Down
11 changes: 0 additions & 11 deletions packages/google-cloud-spanner/tests/unit/_async/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,6 @@ async def unit_of_work(txn, *args, **kw):
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
gax_api.commit.assert_called_once_with(
request=request,
Expand Down Expand Up @@ -1507,7 +1506,6 @@ async def unit_of_work(txn, *args, **kw):
session=session.name,
mutations=txn._mutations,
transaction_id=begin_transaction.return_value.id,
request_options=RequestOptions(),
),
metadata=[
("google-cloud-resource-prefix", database.name),
Expand Down Expand Up @@ -1593,7 +1591,6 @@ async def unit_of_work(txn, *args, **kw):
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
self.assertEqual(
gax_api.commit.call_args_list,
Expand Down Expand Up @@ -1711,7 +1708,6 @@ async def unit_of_work(txn, *args, **kw):
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
self.assertEqual(
gax_api.commit.call_args_list,
Expand Down Expand Up @@ -1808,7 +1804,6 @@ async def unit_of_work(txn, *args, **kw):
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
gax_api.commit.assert_called_once_with(
request=request,
Expand Down Expand Up @@ -1901,7 +1896,6 @@ def _time():
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
gax_api.commit.assert_called_once_with(
request=request,
Expand Down Expand Up @@ -2043,7 +2037,6 @@ def _time():
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
self.assertEqual(
gax_api.commit.call_args_list,
Expand Down Expand Up @@ -2148,7 +2141,6 @@ async def unit_of_work(txn, *args, **kw):
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
return_commit_stats=True,
request_options=RequestOptions(),
)
gax_api.commit.assert_called_once_with(
request=request,
Expand Down Expand Up @@ -2214,7 +2206,6 @@ async def unit_of_work(txn, *args, **kw):
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
return_commit_stats=True,
request_options=RequestOptions(),
)
gax_api.commit.assert_called_once_with(
request=request,
Expand Down Expand Up @@ -2351,7 +2342,6 @@ async def unit_of_work(txn, *args, **kw):
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
gax_api.commit.assert_called_once_with(
request=request,
Expand Down Expand Up @@ -2462,7 +2452,6 @@ async def unit_of_work(txn, *args, **kw):
session=self.SESSION_NAME,
mutations=txn._mutations,
transaction_id=TRANSACTION_ID,
request_options=RequestOptions(),
)
self.assertEqual(
gax_api.commit.call_args_list,
Expand Down
Loading
Loading