mirror of https://github.com/VinGarcia/ksql.git
commit
d2ee98e038
|
@ -38,6 +38,11 @@ func (s SQLAdapter) BeginTx(ctx context.Context) (ksql.Tx, error) {
|
|||
return SQLTx{Tx: tx}, err
|
||||
}
|
||||
|
||||
// Close implements the io.Closer interface
|
||||
func (s SQLAdapter) Close() error {
|
||||
return s.DB.Close()
|
||||
}
|
||||
|
||||
// SQLTx is used to implement the DBAdapter interface and implements
|
||||
// the Tx interface
|
||||
type SQLTx struct {
|
||||
|
|
|
@ -42,6 +42,12 @@ func (p PGXAdapter) BeginTx(ctx context.Context) (ksql.Tx, error) {
|
|||
return PGXTx{tx}, err
|
||||
}
|
||||
|
||||
// Close implements the io.Closer interface
|
||||
func (p PGXAdapter) Close() error {
|
||||
p.db.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// PGXResult is used to implement the DBAdapter interface and implements
|
||||
// the Result interface
|
||||
type PGXResult struct {
|
||||
|
|
|
@ -38,6 +38,11 @@ func (s SQLAdapter) BeginTx(ctx context.Context) (ksql.Tx, error) {
|
|||
return SQLTx{Tx: tx}, err
|
||||
}
|
||||
|
||||
// Close implements the io.Closer interface
|
||||
func (s SQLAdapter) Close() error {
|
||||
return s.DB.Close()
|
||||
}
|
||||
|
||||
// SQLTx is used to implement the DBAdapter interface and implements
|
||||
// the Tx interface
|
||||
type SQLTx struct {
|
||||
|
|
|
@ -38,6 +38,11 @@ func (s SQLAdapter) BeginTx(ctx context.Context) (ksql.Tx, error) {
|
|||
return SQLTx{Tx: tx}, err
|
||||
}
|
||||
|
||||
// Close implements the io.Closer interface
|
||||
func (s SQLAdapter) Close() error {
|
||||
return s.DB.Close()
|
||||
}
|
||||
|
||||
// SQLTx is used to implement the DBAdapter interface and implements
|
||||
// the Tx interface
|
||||
type SQLTx struct {
|
||||
|
|
9
ksql.go
9
ksql.go
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
@ -890,6 +891,14 @@ func (c DB) Transaction(ctx context.Context, fn func(Provider) error) error {
|
|||
}
|
||||
}
|
||||
|
||||
func (c DB) Close() error {
|
||||
closer, ok := c.db.(io.Closer)
|
||||
if ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type nopScanner struct{}
|
||||
|
||||
var nopScannerValue = reflect.ValueOf(&nopScanner{}).Interface()
|
||||
|
|
Loading…
Reference in New Issue