Skip to content

Commit 6641717

Browse files
committed
Fixed mutable behaviour of tx.WithCommit()
1 parent eceec46 commit 6641717

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
* Added retry policy options for topics: `topic/topicoptions.WithReaderCheckRetryErrorFunction`, `topic/topicoptions.WithReaderStartTimeout`, `topic/topicoptions.WithWriterCheckRetryErrorFunction`, `topic/topicoptions.WithWriterStartTimeout`
22
* Refactored `internal/conn` middlewares for `DRY`
33
* Added `trace.tableSessionInfo.LastUsage()` method for get last usage timestamp
4+
* Fixed mutable behaviour of `tx.WithCommit()`
45

56
## v3.41.0
67
* Added option for set interval of auth token update in topic streams

internal/table/transaction.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ func (tx *transaction) ExecuteStatement(
119119
}
120120

121121
func (tx *transaction) WithCommit() table.TransactionActor {
122-
tx.c = tx.c.With(table.CommitTx())
123-
return tx
122+
return &transaction{
123+
id: tx.id,
124+
s: tx.s,
125+
c: table.TxControl(table.WithTxID(tx.id), table.CommitTx()),
126+
committed: tx.committed,
127+
}
124128
}
125129

126130
// CommitTx commits specified active transaction.

table/table.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,7 @@ type Transaction interface {
247247
ctx context.Context,
248248
) (err error)
249249

250-
// WithCommit modifies current transaction with add flag for auto-commit on next Execute[Statement] query
251-
//
252-
// Current transaction will set to committed state after next execute query
250+
// WithCommit returns transaction actor which contains auto-commit flag in next Execute[Statement] query
253251
WithCommit() TransactionActor
254252
}
255253

@@ -381,14 +379,6 @@ func (t *TransactionControl) Desc() *Ydb_Table.TransactionControl {
381379
return &t.desc
382380
}
383381

384-
// With modifies current TransactionControl with options
385-
func (t *TransactionControl) With(opts ...TxControlOption) *TransactionControl {
386-
for _, opt := range opts {
387-
opt((*txControlDesc)(&t.desc))
388-
}
389-
return t
390-
}
391-
392382
// TxControl makes transaction control from given options
393383
func TxControl(opts ...TxControlOption) *TransactionControl {
394384
c := new(TransactionControl)

0 commit comments

Comments
 (0)