sql

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2022 taichi

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conn *sql.Conn, core *Core) *Conn

func (*Conn) Begin

func (conn *Conn) Begin(ctx context.Context) (*Tx, error)

func (*Conn) BeginTx

func (conn *Conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*Conn) Close

func (conn *Conn) Close() error

func (*Conn) Conn

func (conn *Conn) Conn() *sql.Conn

func (*Conn) Exec

func (conn *Conn) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*Conn) Find

func (conn *Conn) Find(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*Conn) FindAll

func (conn *Conn) FindAll(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*Conn) Ping

func (conn *Conn) Ping(ctx context.Context) error

func (*Conn) Prepare

func (conn *Conn) Prepare(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)

func (*Conn) Query

func (conn *Conn) Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)

type ConnBeginTx added in v0.2.0

type ConnBeginTx invocation[Conn, ConnHook, func(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)]

func NewConnBeginTx added in v0.2.0

func NewConnBeginTx(recv *Conn, original func(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)) *ConnBeginTx

func (*ConnBeginTx) Proceed added in v0.2.0

func (invocation *ConnBeginTx) Proceed(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)

type ConnClose added in v0.2.0

type ConnClose invocation[Conn, ConnHook, func() error]

func NewConnClose added in v0.2.0

func NewConnClose(recv *Conn, original func() error) *ConnClose

func (*ConnClose) Proceed added in v0.2.0

func (invocation *ConnClose) Proceed() error

type ConnExec added in v0.2.0

type ConnExec invocation[Conn, ConnHook, func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)]

func NewConnExec added in v0.2.0

func NewConnExec(recv *Conn, original func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)) *ConnExec

func (*ConnExec) Proceed added in v0.2.0

func (invocation *ConnExec) Proceed(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

type ConnFind added in v0.2.0

type ConnFind invocation[Conn, ConnHook, func(ctx context.Context, dest interface{}, query string, args ...interface{}) error]

func NewConnFind added in v0.2.0

func NewConnFind(recv *Conn, original func(ctx context.Context, dest interface{}, query string, args ...interface{}) error) *ConnFind

func (*ConnFind) Proceed added in v0.2.0

func (invocation *ConnFind) Proceed(ctx context.Context, dest interface{}, query string, args ...interface{}) error

type ConnFindAll added in v0.2.0

type ConnFindAll invocation[Conn, ConnHook, func(ctx context.Context, dest interface{}, query string, args ...interface{}) error]

func NewConnFindAll added in v0.2.0

func NewConnFindAll(recv *Conn, original func(ctx context.Context, dest interface{}, query string, args ...interface{}) error) *ConnFindAll

func (*ConnFindAll) Proceed added in v0.2.0

func (invocation *ConnFindAll) Proceed(ctx context.Context, dest interface{}, query string, args ...interface{}) error

type ConnHook added in v0.2.0

type ConnHook struct {
	BeginTx func(invocation *ConnBeginTx, ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)
	Exec    func(invocation *ConnExec, ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Ping    func(invocation *ConnPing, ctx context.Context) error
	Prepare func(invocation *ConnPrepare, ctx context.Context, query string, examples ...interface{}) (*Stmt, error)
	Query   func(invocation *ConnQuery, ctx context.Context, query string, args ...interface{}) (*Rows, error)
	Find    func(invocation *ConnFind, ctx context.Context, dest interface{}, query string, args ...interface{}) error
	FindAll func(invocation *ConnFindAll, ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Close   func(invocation *ConnClose) error
}

type ConnPing added in v0.2.0

type ConnPing invocation[Conn, ConnHook, func(ctx context.Context) error]

func NewConnPing added in v0.2.0

func NewConnPing(recv *Conn, original func(ctx context.Context) error) *ConnPing

func (*ConnPing) Proceed added in v0.2.0

func (invocation *ConnPing) Proceed(ctx context.Context) error

type ConnPrepare added in v0.2.0

type ConnPrepare invocation[Conn, ConnHook, func(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)]

func NewConnPrepare added in v0.2.0

func NewConnPrepare(recv *Conn, original func(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)) *ConnPrepare

func (*ConnPrepare) Proceed added in v0.2.0

func (invocation *ConnPrepare) Proceed(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)

type ConnQuery added in v0.2.0

type ConnQuery invocation[Conn, ConnHook, func(ctx context.Context, query string, args ...interface{}) (*Rows, error)]

func NewConnQuery added in v0.2.0

func NewConnQuery(recv *Conn, original func(ctx context.Context, query string, args ...interface{}) (*Rows, error)) *ConnQuery

func (*ConnQuery) Proceed added in v0.2.0

func (invocation *ConnQuery) Proceed(ctx context.Context, query string, args ...interface{}) (*Rows, error)

type Core added in v0.2.0

type Core struct {
	*kra.Core
	// contains filtered or unexported fields
}

func NewCore added in v0.2.0

func NewCore(core *kra.Core, hooks ...interface{}) *Core

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB(db *sql.DB, core *Core) *DB

func Open

func Open(core *Core, driverName, dataSourceName string) (*DB, error)

func (*DB) Begin

func (db *DB) Begin(ctx context.Context) (*Tx, error)

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Conn added in v0.2.0

func (db *DB) Conn(ctx context.Context) (*Conn, error)

func (*DB) DB

func (db *DB) DB() *sql.DB

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*DB) Find

func (db *DB) Find(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*DB) FindAll

func (db *DB) FindAll(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*DB) Ping

func (db *DB) Ping(ctx context.Context) error

func (*DB) Prepare

func (db *DB) Prepare(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)

func (*DB) Query

func (db *DB) Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)

type DBBeginTx added in v0.2.0

type DBBeginTx invocation[DB, DBHook, func(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)]

func NewDBBeginTx added in v0.2.0

func NewDBBeginTx(recv *DB, original func(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)) *DBBeginTx

func (*DBBeginTx) Proceed added in v0.2.0

func (invocation *DBBeginTx) Proceed(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)

type DBClose added in v0.2.0

type DBClose invocation[DB, DBHook, func() error]

func NewDBClose added in v0.2.0

func NewDBClose(recv *DB, original func() error) *DBClose

func (*DBClose) Proceed added in v0.2.0

func (invocation *DBClose) Proceed() error

type DBExec added in v0.2.0

type DBExec invocation[DB, DBHook, func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)]

func NewDBExec added in v0.2.0

func NewDBExec(recv *DB, original func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)) *DBExec

func (*DBExec) Proceed added in v0.2.0

func (invocation *DBExec) Proceed(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

type DBFind added in v0.2.0

type DBFind invocation[DB, DBHook, func(ctx context.Context, dest interface{}, query string, args ...interface{}) error]

func NewDBFind added in v0.2.0

func NewDBFind(recv *DB, original func(ctx context.Context, dest interface{}, query string, args ...interface{}) error) *DBFind

func (*DBFind) Proceed added in v0.2.0

func (invocation *DBFind) Proceed(ctx context.Context, dest interface{}, query string, args ...interface{}) error

type DBFindAll added in v0.2.0

type DBFindAll invocation[DB, DBHook, func(ctx context.Context, dest interface{}, query string, args ...interface{}) error]

func NewDBFindAll added in v0.2.0

func NewDBFindAll(recv *DB, original func(ctx context.Context, dest interface{}, query string, args ...interface{}) error) *DBFindAll

func (*DBFindAll) Proceed added in v0.2.0

func (invocation *DBFindAll) Proceed(ctx context.Context, dest interface{}, query string, args ...interface{}) error

type DBHook added in v0.2.0

type DBHook struct {
	BeginTx func(invocation *DBBeginTx, ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)
	Exec    func(invocation *DBExec, ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Ping    func(invocation *DBPing, ctx context.Context) error
	Prepare func(invocation *DBPrepare, ctx context.Context, query string, examples ...interface{}) (*Stmt, error)
	Query   func(invocation *DBQuery, ctx context.Context, query string, args ...interface{}) (*Rows, error)
	Find    func(invocation *DBFind, ctx context.Context, dest interface{}, query string, args ...interface{}) error
	FindAll func(invocation *DBFindAll, ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Close   func(invocation *DBClose) error
}

type DBPing added in v0.2.0

type DBPing invocation[DB, DBHook, func(ctx context.Context) error]

func NewDBPing added in v0.2.0

func NewDBPing(recv *DB, original func(ctx context.Context) error) *DBPing

func (*DBPing) Proceed added in v0.2.0

func (invocation *DBPing) Proceed(ctx context.Context) error

type DBPrepare added in v0.2.0

type DBPrepare invocation[DB, DBHook, func(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)]

func NewDBPrepare added in v0.2.0

func NewDBPrepare(recv *DB, original func(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)) *DBPrepare

func (*DBPrepare) Proceed added in v0.2.0

func (invocation *DBPrepare) Proceed(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)

type DBQuery added in v0.2.0

type DBQuery invocation[DB, DBHook, func(ctx context.Context, query string, args ...interface{}) (*Rows, error)]

func NewDBQuery added in v0.2.0

func NewDBQuery(recv *DB, original func(ctx context.Context, query string, args ...interface{}) (*Rows, error)) *DBQuery

func (*DBQuery) Proceed added in v0.2.0

func (invocation *DBQuery) Proceed(ctx context.Context, query string, args ...interface{}) (*Rows, error)

type HookHolster added in v0.2.0

type HookHolster struct {
	Core []*kra.CoreHook
	Conn []*ConnHook
	DB   []*DBHook
	Tx   []*TxHook
	Stmt []*StmtHook
	Rows []*RowsHook
}

func NewHookHolster added in v0.2.0

func NewHookHolster(hooks ...interface{}) *HookHolster

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

func NewRows added in v0.2.0

func NewRows(core *Core, rows *sql.Rows) *Rows

func (*Rows) Close

func (rows *Rows) Close() error

func (*Rows) Rows

func (rows *Rows) Rows() *sql.Rows

func (*Rows) Scan

func (rows *Rows) Scan(dest interface{}) error

type RowsClose added in v0.2.0

type RowsClose invocation[Rows, RowsHook, func() error]

func NewRowsClose added in v0.2.0

func NewRowsClose(recv *Rows, original func() error) *RowsClose

func (*RowsClose) Proceed added in v0.2.0

func (invocation *RowsClose) Proceed() error

type RowsErr added in v0.2.0

type RowsErr invocation[Rows, RowsHook, func() error]

func NewRowsErr added in v0.2.0

func NewRowsErr(recv *Rows, original func() error) *RowsErr

func (*RowsErr) Proceed added in v0.2.0

func (invocation *RowsErr) Proceed() error

type RowsHook added in v0.2.0

type RowsHook struct {
	Next  func(invocation *RowsNext) bool
	Err   func(invocation *RowsErr) error
	Scan  func(invocation *RowsScan, dest interface{}) error
	Close func(invocation *RowsClose) error
}

type RowsNext added in v0.2.0

type RowsNext invocation[Rows, RowsHook, func() bool]

func NewRowsNext added in v0.2.0

func NewRowsNext(recv *Rows, original func() bool) *RowsNext

func (*RowsNext) Proceed added in v0.2.0

func (invocation *RowsNext) Proceed() bool

type RowsScan added in v0.2.0

type RowsScan invocation[Rows, RowsHook, func(dest interface{}) error]

func NewRowsScan added in v0.2.0

func NewRowsScan(recv *Rows, original func(dest interface{}) error) *RowsScan

func (*RowsScan) Proceed added in v0.2.0

func (invocation *RowsScan) Proceed(dest interface{}) error

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

func (*Stmt) Close

func (stmt *Stmt) Close() error

func (*Stmt) Exec

func (stmt *Stmt) Exec(ctx context.Context, args ...interface{}) (sql.Result, error)

func (*Stmt) Query

func (stmt *Stmt) Query(ctx context.Context, args ...interface{}) (*Rows, error)

func (*Stmt) Stmt

func (stmt *Stmt) Stmt() *sql.Stmt

type StmtClose added in v0.2.0

type StmtClose invocation[Stmt, StmtHook, func() error]

func NewStmtClose added in v0.2.0

func NewStmtClose(recv *Stmt, original func() error) *StmtClose

func (*StmtClose) Proceed added in v0.2.0

func (invocation *StmtClose) Proceed() error

type StmtExec added in v0.2.0

type StmtExec invocation[Stmt, StmtHook, func(ctx context.Context, args ...interface{}) (sql.Result, error)]

func NewStmtExec added in v0.2.0

func NewStmtExec(recv *Stmt, original func(ctx context.Context, args ...interface{}) (sql.Result, error)) *StmtExec

func (*StmtExec) Proceed added in v0.2.0

func (invocation *StmtExec) Proceed(ctx context.Context, args ...interface{}) (sql.Result, error)

type StmtHook added in v0.2.0

type StmtHook struct {
	Exec  func(invocation *StmtExec, ctx context.Context, args ...interface{}) (sql.Result, error)
	Query func(invocation *StmtQuery, ctx context.Context, args ...interface{}) (*Rows, error)
	Close func(invocation *StmtClose) error
}

type StmtQuery added in v0.2.0

type StmtQuery invocation[Stmt, StmtHook, func(ctx context.Context, args ...interface{}) (*Rows, error)]

func NewStmtQuery added in v0.2.0

func NewStmtQuery(recv *Stmt, original func(ctx context.Context, args ...interface{}) (*Rows, error)) *StmtQuery

func (*StmtQuery) Proceed added in v0.2.0

func (invocation *StmtQuery) Proceed(ctx context.Context, args ...interface{}) (*Rows, error)

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Exec

func (tx *Tx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*Tx) Find

func (tx *Tx) Find(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*Tx) FindAll

func (tx *Tx) FindAll(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*Tx) Prepare

func (tx *Tx) Prepare(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)

func (*Tx) Query

func (tx *Tx) Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)

func (*Tx) Rollback

func (tx *Tx) Rollback() error

func (*Tx) Tx

func (tx *Tx) Tx() *sql.Tx

type TxBeginTx added in v0.2.0

type TxBeginTx invocation[Tx, TxHook, func(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)]

func NewTxBeginTx added in v0.2.0

func NewTxBeginTx(recv *Tx, original func(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)) *TxBeginTx

func (*TxBeginTx) Proceed added in v0.2.0

func (invocation *TxBeginTx) Proceed(ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)

type TxClose added in v0.2.0

type TxClose invocation[Tx, TxHook, func() error]

func NewTxClose added in v0.2.0

func NewTxClose(recv *Tx, original func() error) *TxClose

func (*TxClose) Proceed added in v0.2.0

func (invocation *TxClose) Proceed() error

type TxCommit added in v0.2.0

type TxCommit invocation[Tx, TxHook, func() error]

func NewTxCommit added in v0.2.0

func NewTxCommit(recv *Tx, original func() error) *TxCommit

func (*TxCommit) Proceed added in v0.2.0

func (invocation *TxCommit) Proceed() error

type TxExec added in v0.2.0

type TxExec invocation[Tx, TxHook, func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)]

func NewTxExec added in v0.2.0

func NewTxExec(recv *Tx, original func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)) *TxExec

func (*TxExec) Proceed added in v0.2.0

func (invocation *TxExec) Proceed(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

type TxFind added in v0.2.0

type TxFind invocation[Tx, TxHook, func(ctx context.Context, dest interface{}, query string, args ...interface{}) error]

func NewTxFind added in v0.2.0

func NewTxFind(recv *Tx, original func(ctx context.Context, dest interface{}, query string, args ...interface{}) error) *TxFind

func (*TxFind) Proceed added in v0.2.0

func (invocation *TxFind) Proceed(ctx context.Context, dest interface{}, query string, args ...interface{}) error

type TxFindAll added in v0.2.0

type TxFindAll invocation[Tx, TxHook, func(ctx context.Context, dest interface{}, query string, args ...interface{}) error]

func NewTxFindAll added in v0.2.0

func NewTxFindAll(recv *Tx, original func(ctx context.Context, dest interface{}, query string, args ...interface{}) error) *TxFindAll

func (*TxFindAll) Proceed added in v0.2.0

func (invocation *TxFindAll) Proceed(ctx context.Context, dest interface{}, query string, args ...interface{}) error

type TxHook added in v0.2.0

type TxHook struct {
	BeginTx  func(invocation *TxBeginTx, ctx context.Context, txOptions *sql.TxOptions) (*Tx, error)
	Exec     func(invocation *TxExec, ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Ping     func(invocation *TxPing, ctx context.Context) error
	Prepare  func(invocation *TxPrepare, ctx context.Context, query string, examples ...interface{}) (*Stmt, error)
	Query    func(invocation *TxQuery, ctx context.Context, query string, args ...interface{}) (*Rows, error)
	Find     func(invocation *TxFind, ctx context.Context, dest interface{}, query string, args ...interface{}) error
	FindAll  func(invocation *TxFindAll, ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Commit   func(invocation *TxCommit) error
	Rollback func(invocation *TxRollback) error
	Close    func(invocation *TxClose) error
}

type TxPing added in v0.2.0

type TxPing invocation[Tx, TxHook, func(ctx context.Context) error]

func NewTxPing added in v0.2.0

func NewTxPing(recv *Tx, original func(ctx context.Context) error) *TxPing

func (*TxPing) Proceed added in v0.2.0

func (invocation *TxPing) Proceed(ctx context.Context) error

type TxPrepare added in v0.2.0

type TxPrepare invocation[Tx, TxHook, func(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)]

func NewTxPrepare added in v0.2.0

func NewTxPrepare(recv *Tx, original func(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)) *TxPrepare

func (*TxPrepare) Proceed added in v0.2.0

func (invocation *TxPrepare) Proceed(ctx context.Context, query string, examples ...interface{}) (*Stmt, error)

type TxQuery added in v0.2.0

type TxQuery invocation[Tx, TxHook, func(ctx context.Context, query string, args ...interface{}) (*Rows, error)]

func NewTxQuery added in v0.2.0

func NewTxQuery(recv *Tx, original func(ctx context.Context, query string, args ...interface{}) (*Rows, error)) *TxQuery

func (*TxQuery) Proceed added in v0.2.0

func (invocation *TxQuery) Proceed(ctx context.Context, query string, args ...interface{}) (*Rows, error)

type TxRollback added in v0.2.0

type TxRollback invocation[Tx, TxHook, func() error]

func NewTxRollback added in v0.2.0

func NewTxRollback(recv *Tx, original func() error) *TxRollback

func (*TxRollback) Proceed added in v0.2.0

func (invocation *TxRollback) Proceed() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL