
Exporting sqlCommon as SQLCommon. This allows passing alternate implementations of the database connection, or wrapping the connection with middleware. This change didn't change any usages of the database variables. All usages were already only using the functions defined in SQLCommon. This does cause a breaking change in Dialect, since *sql.DB was referenced in the interface.
21 lines
498 B
Go
21 lines
498 B
Go
package gorm
|
|
|
|
import "database/sql"
|
|
|
|
// SQLCommon is the minimal database connection functionality gorm requires. Implemented by *sql.DB.
|
|
type SQLCommon interface {
|
|
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
|
|
}
|
|
|
|
type sqlDb interface {
|
|
Begin() (*sql.Tx, error)
|
|
}
|
|
|
|
type sqlTx interface {
|
|
Commit() error
|
|
Rollback() error
|
|
}
|