2013-11-11 09:16:08 +04:00
|
|
|
package gorm
|
|
|
|
|
2019-06-10 15:33:20 +03:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
)
|
2013-11-11 09:16:08 +04:00
|
|
|
|
2017-03-14 23:32:38 +03:00
|
|
|
// SQLCommon is the minimal database connection functionality gorm requires. Implemented by *sql.DB.
|
|
|
|
type SQLCommon interface {
|
2013-11-11 09:16:08 +04:00
|
|
|
Exec(query string, args ...interface{}) (sql.Result, error)
|
|
|
|
Prepare(query string) (*sql.Stmt, error)
|
|
|
|
Query(query string, args ...interface{}) (*sql.Rows, error)
|
|
|
|
QueryRow(query string, args ...interface{}) *sql.Row
|
|
|
|
}
|
|
|
|
|
2013-11-16 04:15:21 +04:00
|
|
|
type sqlDb interface {
|
2013-11-11 09:16:08 +04:00
|
|
|
Begin() (*sql.Tx, error)
|
2019-06-10 15:33:20 +03:00
|
|
|
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
|
2013-11-11 09:16:08 +04:00
|
|
|
}
|
|
|
|
|
2013-11-16 04:15:21 +04:00
|
|
|
type sqlTx interface {
|
2013-11-11 09:16:08 +04:00
|
|
|
Commit() error
|
|
|
|
Rollback() error
|
|
|
|
}
|