-
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 |
|---|---|---|
|
|
@@ -446,8 +446,7 @@ def commit(self): | |
| """Makes a ``MutateRow`` API request. | ||
|
|
||
| If no mutations have been created in the row, no request is made and a | ||
| :class:`~google.rpc.status_pb2.Status` with code INVALID_ARGUMENT is returned | ||
| instead. | ||
| ValueError is raised instead. | ||
|
|
||
| Mutations are applied atomically and in order, meaning that earlier | ||
| mutations can be masked / negated by later ones. Cells already present | ||
|
|
@@ -466,6 +465,7 @@ def commit(self): | |
| :rtype: :class:`~google.rpc.status_pb2.Status` | ||
| :returns: A response status (`google.rpc.status_pb2.Status`) | ||
| representing success or failure of the row committed. | ||
| :raises: ValueError: if no mutations have been created in the row | ||
| """ | ||
| 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 |
||
|
|
@@ -479,12 +479,8 @@ 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), | ||
| ) | ||
| except ValueError: | ||
| raise | ||
|
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. nit: this doesn't do anything, does it? Doesn't catching and raising do the same thing as not catching? |
||
| finally: | ||
| self.clear() | ||
|
|
||
|
|
||
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