-
Notifications
You must be signed in to change notification settings - Fork 65
feat: Rerouted DirectRow.commit to use MutateRow #1276
Changes from 1 commit
09a22fe
9caad04
038937a
8b8a4ca
e5dc1cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -467,7 +467,7 @@ def commit(self): | |
| """ | ||
| try: | ||
| self._table._table_impl.mutate_row(self.row_key, self._get_mutations()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mutate_row has automatic retries. Is that expected? Did the previous implementation retry?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous implementation used |
||
| return status_pb2.Status() | ||
| return status_pb2.Status(code=code_pb2.OK) | ||
| except GoogleAPICallError as e: | ||
| # If the RPC call returns an error, extract the error into a status object, if possible. | ||
| return status_pb2.Status( | ||
|
|
@@ -477,6 +477,12 @@ def commit(self): | |
| message=e.message, | ||
| details=e.details, | ||
| ) | ||
|
Comment on lines
+470
to
+481
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| except ValueError as e: | ||
| # _table_impl.mutate_row raises a ValueError if invalid arguments are provided. | ||
| return status_pb2.Status( | ||
| code=code_pb2.INVALID_ARGUMENT, | ||
| message=str(e), | ||
| ) | ||
| finally: | ||
| self.clear() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1092,10 +1092,10 @@ def test_table_direct_row_input_errors(data_table, rows_to_delete): | |
| resp = row.commit() | ||
| assert resp.code == StatusCode.INVALID_ARGUMENT.value[0] | ||
|
|
||
| # Not having any mutations gives a ValueError enforced on the client side. | ||
| # Not having any mutations gives an INVALID_ARGUMENT | ||
| row.clear() | ||
| with pytest.raises(ValueError): | ||
| row.commit() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised this part had to change, since it seems counter to what the docstring suggested? Was the previous behaviour to throw an error? |
||
| resp = row.commit() | ||
| assert resp.code == StatusCode.INVALID_ARGUMENT.value[0] | ||
|
|
||
|
|
||
| def test_table_conditional_row_input_errors(data_table, rows_to_delete): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring says "If no mutations have been created in the row, no request is made.". But it looks like mutate_row raises a ValueError if no mutations are present.
You should probably catch and swallow that exception, and make sure this case is handled in tests