-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f5638b
commit 476f72e
Showing
14 changed files
with
305 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ var _ Identifier = LazyID{} | |
|
||
const ( | ||
LazyTxID = "LAZY_TX" | ||
FakeTxID = "FAKE_TX" | ||
) | ||
|
||
type ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package query | ||
|
||
import ( | ||
"context" | ||
"database/sql/driver" | ||
|
||
"github.com/ydb-platform/ydb-go-sdk/v3/internal/params" | ||
"github.com/ydb-platform/ydb-go-sdk/v3/internal/tx" | ||
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" | ||
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/conn" | ||
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/conn/table/badconn" | ||
) | ||
|
||
type txFake struct { | ||
conn *Conn | ||
ctx context.Context //nolint:containedctx | ||
} | ||
|
||
func (t *txFake) Exec(ctx context.Context, sql string, params *params.Params) (driver.Result, error) { | ||
result, err := t.conn.Exec(ctx, sql, params) | ||
if err != nil { | ||
return nil, xerrors.WithStackTrace(err) | ||
} | ||
|
||
return result, nil | ||
} | ||
|
||
func (t *txFake) Query(ctx context.Context, sql string, params *params.Params) (driver.RowsNextResultSet, error) { | ||
rows, err := t.conn.Query(ctx, sql, params) | ||
if err != nil { | ||
return nil, xerrors.WithStackTrace(err) | ||
} | ||
|
||
return rows, nil | ||
} | ||
|
||
func (t *txFake) ID() string { | ||
return tx.FakeTxID | ||
} | ||
|
||
func beginTxFake(ctx context.Context, c *Conn) conn.Tx { | ||
return &txFake{ | ||
conn: c, | ||
ctx: ctx, | ||
} | ||
} | ||
|
||
func (t *txFake) Commit(ctx context.Context) (err error) { | ||
if !t.conn.isReady() { | ||
return badconn.Map(xerrors.WithStackTrace(errNotReadyConn)) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (t *txFake) Rollback(ctx context.Context) (err error) { | ||
if !t.conn.isReady() { | ||
return badconn.Map(xerrors.WithStackTrace(errNotReadyConn)) | ||
} | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.