Issue: Inconsistency in Transaction.execute_update
Documentation Regarding param_types
#1276
Labels
api: spanner
Issues related to the googleapis/python-spanner API.
Overview
While reading through the
Transaction
class documentation, I noticed a potential inconsistency or missing implementation regarding theparam_types
argument in theexecute_update
method.The documentation states the following about param_types:
Additionally, the docstring for the helper method
_make_params_pb
, which is used byexecute_update
, provides this information:Contrary to the documentation, the
_make_params_pb
method does not appear to include any conditions to raise a ValueError. Furthermore, when I run the following code without explicitly providingparam_types
, no error is raised, and the update works as expected.Question
Is the documentation incorrect in stating that
param_types
is required when params are passed, or is the implementation missing theValueError
raises described in the docstring?Environment details
3.11.9
24.0
google-cloud-spanner
version:3.51.0
Steps to reproduce
Use the
Transaction.execute_update
method with the following parameters:param_types
.Observe that no error is raised, despite the documentation indicating that
param_types
is required whenparams
are provided.Code example
Expected behavior
According to the documentation, param_types is required when params are passed. If param_types is not provided, a ValueError should be raised.
Observed behavior
No error is raised, and the query executes successfully.
Stack trace
No error or exception is raised, so no stack trace is available.
Suggestions
1. Add a
ValueError
in the implementation:Update the
_make_params_pb
method to raise aValueError
ifparam_types
isNone
while params is notNone
. For example:Update the documentation to reflect the actual behavior
Modify the docstring in
_make_params_pb
and theTransaction.execute_update
method to clarify thatparam_types
is optional, even when params are passed, and that no error will be raised if only one of them is provided. For example:The text was updated successfully, but these errors were encountered: