This repository was archived by the owner on Dec 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,10 @@ StatusOr<CommitResult> Client::Commit(
251251 std::move (default_commit_backoff_policy));
252252}
253253
254+ StatusOr<CommitResult> Client::Commit (Mutations mutations) {
255+ return Commit ([&mutations](Transaction const &) { return mutations; });
256+ }
257+
254258StatusOr<CommitResult> Client::Commit (Transaction transaction,
255259 Mutations mutations) {
256260 return conn_->Commit ({std::move (transaction), std::move (mutations)});
Original file line number Diff line number Diff line change @@ -480,6 +480,14 @@ class Client {
480480 StatusOr<CommitResult> Commit (
481481 std::function<StatusOr<Mutations>(Transaction)> const & mutator);
482482
483+ /* *
484+ * Commits the given @p mutations atomically in order.
485+ *
486+ * This function uses the re-run loop described above with the default
487+ * policies.
488+ */
489+ StatusOr<CommitResult> Commit (Mutations mutations);
490+
483491 /* *
484492 * Commits a read-write transaction.
485493 *
Original file line number Diff line number Diff line change @@ -684,6 +684,23 @@ TEST(ClientTest, CommitMutatorPermanentFailure) {
684684 EXPECT_EQ (1 , commit_attempts); // no reruns
685685}
686686
687+ TEST (ClientTest, CommitMutations) {
688+ auto conn = std::make_shared<MockConnection>();
689+ auto mutation = MakeDeleteMutation (" table" , KeySet::All ());
690+ auto timestamp = internal::TimestampFromRFC3339 (" 2020-02-28T04:49:17.335Z" );
691+ ASSERT_STATUS_OK (timestamp);
692+ EXPECT_CALL (*conn, Commit (_))
693+ .WillOnce ([&mutation, ×tamp](Connection::CommitParams const & cp) {
694+ EXPECT_EQ (cp.mutations , Mutations{mutation});
695+ return CommitResult{*timestamp};
696+ });
697+
698+ Client client (conn);
699+ auto result = client.Commit ({mutation});
700+ EXPECT_STATUS_OK (result);
701+ EXPECT_EQ (*timestamp, result->commit_timestamp );
702+ }
703+
687704MATCHER (DoesNotHaveSession, " not bound to a session" ) {
688705 return internal::Visit (
689706 arg, [&](internal::SessionHolder& session,
You can’t perform that action at this time.
0 commit comments