Debian Codegraph @

interfaces.go

raw
1 package gorm
2
3 import (
4 "context"
5 "database/sql"
6
7 "gorm.io/gorm/clause"
8 "gorm.io/gorm/schema"
9 )
10
11 // Dialector GORM database dialector
12 type Dialector interface {
13 Name() string
14 Initialize(*DB) error
15 Migrator(db *DB) Migrator
16 DataTypeOf(*schema.Field) string
17 DefaultValueOf(*schema.Field) clause.Expression
18 BindVarTo(writer clause.Writer, stmt *Statement, v interface{})
19 QuoteTo(clause.Writer, string)
20 Explain(sql string, vars ...interface{}) string
21 }
22
23 // Plugin GORM plugin interface
24 type Plugin interface {
25 Name() string
26 Initialize(*DB) error
27 }
28
29 type ParamsFilter interface {
30 ParamsFilter(ctx context.Context, sql string, params ...interface{}) (string, []interface{})
31 }
32
33 // ConnPool db conns pool interface
34 type ConnPool interface {
35 PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
36 ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
37 QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
38 QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
39 }
40
41 // SavePointerDialectorInterface save pointer interface
42 type SavePointerDialectorInterface interface {
43 SavePoint(tx *DB, name string) error
44 RollbackTo(tx *DB, name string) error
45 }
46
47 // TxBeginner tx beginner
48 type TxBeginner interface {
49 BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
50 }
51
52 // ConnPoolBeginner conn pool beginner
53 type ConnPoolBeginner interface {
54 BeginTx(ctx context.Context, opts *sql.TxOptions) (ConnPool, error)
55 }
56
57 // TxCommitter tx committer
58 type TxCommitter interface {
59 Commit() error
60 Rollback() error
61 }
62
63 // Tx sql.Tx interface
64 type Tx interface {
65 ConnPool
66 TxCommitter
67 StmtContext(ctx context.Context, stmt *sql.Stmt) *sql.Stmt
68 }
69
70 // Valuer gorm valuer interface
71 type Valuer interface {
72 GormValue(context.Context, *DB) clause.Expr
73 }
74
75 // GetDBConnector SQL db connector
76 type GetDBConnector interface {
77 GetDBConn() (*sql.DB, error)
78 }
79
80 // Rows rows interface
81 type Rows interface {
82 Columns() ([]string, error)
83 ColumnTypes() ([]*sql.ColumnType, error)
84 Next() bool
85 Scan(dest ...interface{}) error
86 Err() error
87 Close() error
88 }
89
90 type ErrorTranslator interface {
91 Translate(err error) error
92 }