Documentation ¶
Overview ¶
Example (BulkOperation) ¶
package main import ( "database/sql" "fmt" "log" "os" "strings" "github.com/kamichidu/goen" _ "github.com/kamichidu/goen/dialect/sqlite3" _ "github.com/mattn/go-sqlite3" ) func main() { db, err := sql.Open("sqlite3", "./sqlite.db") if err != nil { panic(err) } defer db.Close() ddl := []string{ `drop table if exists testing`, `create table testing (id integer primary key, name varchar(256))`, } if _, err := db.Exec(strings.Join(ddl, ";")); err != nil { panic(err) } dbc := goen.NewDBContext("sqlite3", db) // set patch compiler, it compiles patches to bulk dbc.Compiler = goen.BulkCompiler for i := 0; i < 3; i++ { dbc.Patch(goen.InsertPatch( "testing", []string{"name"}, []interface{}{fmt.Sprintf("name-%d", i)}, )) } dbc.DebugMode(true) dbc.Logger = log.New(os.Stdout, "", 0) if err := dbc.SaveChanges(); err != nil { panic(err) } }
Output: goen: "INSERT INTO `testing` (`name`) VALUES (?),(?),(?)" with [name-0 name-1 name-2]
Example (CachingPreparedStatements) ¶
package main import ( "database/sql" "fmt" "strings" "github.com/kamichidu/goen" _ "github.com/kamichidu/goen/dialect/sqlite3" _ "github.com/mattn/go-sqlite3" ) func main() { db, err := sql.Open("sqlite3", "./sqlite.db") if err != nil { panic(err) } defer db.Close() ddl := []string{ `drop table if exists testing`, `create table testing (id integer primary key, name varchar(256))`, } if _, err := db.Exec(strings.Join(ddl, ";")); err != nil { panic(err) } // goen.StmtCacher caches *sql.Stmt until closed. preparedQueryRunner := goen.NewStmtCacher(db) defer preparedQueryRunner.Close() dbc := goen.NewDBContext("sqlite3", db) // set preparedQueryRunner to dbc.QueryRunner. dbc.QueryRunner = preparedQueryRunner fmt.Printf("cached statements %v\n", preparedQueryRunner.StmtStats().CachedStmts) err = goen.TxScope(dbc.DB.Begin())(func(tx *sql.Tx) error { // txc also use preparedQueryRunner when dbc uses it. txc := dbc.UseTx(tx) txc.Patch(&goen.Patch{ Kind: goen.PatchInsert, TableName: "testing", Columns: []string{"name"}, Values: []interface{}{"kamichidu"}, }) return txc.SaveChanges() }) if err != nil { panic(err) } fmt.Printf("cached statements %v\n", preparedQueryRunner.StmtStats().CachedStmts) var count int if err := dbc.QueryRow(`select count(*) from testing`).Scan(&count); err != nil { panic(err) } fmt.Printf("%v records found\n", count) fmt.Printf("cached statements %v\n", preparedQueryRunner.StmtStats().CachedStmts) }
Output: cached statements 0 cached statements 1 1 records found cached statements 2
Example (QueryCount) ¶
package main import ( "database/sql" "fmt" "strings" "github.com/kamichidu/goen" _ "github.com/kamichidu/goen/dialect/sqlite3" _ "github.com/mattn/go-sqlite3" ) func main() { db, err := sql.Open("sqlite3", "./sqlite.db") if err != nil { panic(err) } defer db.Close() ddl := []string{ `drop table if exists testing`, `create table testing (id integer primary key, name varchar(256))`, } if _, err := db.Exec(strings.Join(ddl, ";")); err != nil { panic(err) } dbc := goen.NewDBContext("sqlite3", db) for i := 0; i < 3; i++ { dbc.Patch(goen.InsertPatch( "testing", []string{"name"}, []interface{}{fmt.Sprintf("name-%d", i)}, )) } if err := dbc.SaveChanges(); err != nil { panic(err) } row := dbc.QueryRow(`select count(*) from testing`) var count int64 if err := row.Scan(&count); err != nil { panic(err) } fmt.Printf("dbc founds %d records\n", count) var records []map[string]interface{} rows, err := dbc.Query(`select id, name from testing`) if err != nil { panic(err) } defer rows.Close() if err := dbc.Scan(rows, &records); err != nil { panic(err) } fmt.Print("records:\n") for _, record := range records { fmt.Printf("id=%d name=%q\n", record["id"], record["name"]) } }
Output: dbc founds 3 records records: id=1 name="name-0" id=2 name="name-1" id=3 name="name-2"
Example (Transaction) ¶
package main import ( "database/sql" "fmt" "strings" "github.com/kamichidu/goen" _ "github.com/kamichidu/goen/dialect/sqlite3" _ "github.com/mattn/go-sqlite3" ) func main() { db, err := sql.Open("sqlite3", "./sqlite.db") if err != nil { panic(err) } defer db.Close() ddl := []string{ `drop table if exists testing`, `create table testing (id integer primary key, name varchar(256))`, } if _, err := db.Exec(strings.Join(ddl, ";")); err != nil { panic(err) } dbc := goen.NewDBContext("sqlite3", db) tx, err := dbc.DB.Begin() if err != nil { panic(err) } txc := dbc.UseTx(tx) if txc.Tx != tx { panic("UseTx makes clones DBContext and set Tx with given value") } txc.Patch(&goen.Patch{ Kind: goen.PatchInsert, TableName: "testing", Columns: []string{"name"}, Values: []interface{}{"kamichidu"}, }) if err := txc.SaveChanges(); err != nil { panic(err) } func() { rows, err := dbc.Query(`select * from testing`) if err != nil { panic(err) } defer rows.Close() var records []map[string]interface{} if err := dbc.Scan(rows, &records); err != nil { panic(err) } fmt.Printf("dbc founds %d records when not committed yet\n", len(records)) }() func() { rows, err := txc.Query(`select * from testing`) if err != nil { panic(err) } defer rows.Close() var records []map[string]interface{} if err := txc.Scan(rows, &records); err != nil { panic(err) } fmt.Printf("txc founds %d records when not committed yet since it's same transaction\n", len(records)) }() if err := tx.Commit(); err != nil { panic(err) } func() { rows, err := dbc.Query(`select * from testing`) if err != nil { panic(err) } defer rows.Close() var records []map[string]interface{} if err := dbc.Scan(rows, &records); err != nil { panic(err) } fmt.Printf("dbc founds %d records after committed\n", len(records)) }() func() { _, err := txc.Query(`select * from testing`) if err == sql.ErrTxDone { fmt.Print("txc returns an error sql.ErrTxDone after committed\n") } }() }
Output: dbc founds 0 records when not committed yet txc founds 1 records when not committed yet since it's same transaction dbc founds 1 records after committed txc returns an error sql.ErrTxDone after committed
Index ¶
- func Register(name string, dialect dialect.Dialect)
- func TxScope(tx *sql.Tx, err error) txScope
- type BulkCompilerOptions
- type Cardinality
- type CompilerHook
- type CompilerOptions
- type DBContext
- func (dbc *DBContext) CompilePatch() *SqlizerList
- func (dbc *DBContext) DebugMode(enabled bool)
- func (dbc *DBContext) Dialect() dialect.Dialect
- func (dbc *DBContext) Include(v interface{}, sc *ScopeCache, loader IncludeLoader) error
- func (dbc *DBContext) IncludeContext(ctx context.Context, v interface{}, sc *ScopeCache, loader IncludeLoader) error
- func (dbc *DBContext) Patch(v *Patch)
- func (dbc *DBContext) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (dbc *DBContext) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (dbc *DBContext) QueryRow(query string, args ...interface{}) *sql.Row
- func (dbc *DBContext) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (dbc *DBContext) QueryRowSqlizer(sqlizer sqr.Sqlizer) *sql.Row
- func (dbc *DBContext) QueryRowSqlizerContext(ctx context.Context, sqlizer sqr.Sqlizer) *sql.Row
- func (dbc *DBContext) QuerySqlizer(sqlizer sqr.Sqlizer) (*sql.Rows, error)
- func (dbc *DBContext) QuerySqlizerContext(ctx context.Context, sqlizer sqr.Sqlizer) (*sql.Rows, error)
- func (dbc *DBContext) SaveChanges() error
- func (dbc *DBContext) SaveChangesContext(ctx context.Context) error
- func (dbc *DBContext) Scan(rows *sql.Rows, v interface{}) error
- func (dbc *DBContext) UseTx(tx *sql.Tx) *DBContext
- type IncludeBuffer
- type IncludeLoader
- type IncludeLoaderFunc
- type IncludeLoaderList
- type Logger
- type LoggerFunc
- type MapRowKey
- type MetaColumn
- type MetaSchema
- type MetaTable
- type Patch
- type PatchCompiler
- type PatchCompilerFunc
- type PatchElement
- type PatchKind
- type PatchList
- func (l *PatchList) Back() *PatchElement
- func (l *PatchList) Front() *PatchElement
- func (l *PatchList) Init() *PatchList
- func (l *PatchList) InsertAfter(v *Patch, mark *PatchElement) *PatchElement
- func (l *PatchList) InsertBefore(v *Patch, mark *PatchElement) *PatchElement
- func (l *PatchList) Len() int
- func (l *PatchList) MoveAfter(e *PatchElement, mark *PatchElement)
- func (l *PatchList) MoveBefore(e *PatchElement, mark *PatchElement)
- func (l *PatchList) MoveToBack(e *PatchElement)
- func (l *PatchList) MoveToFront(e *PatchElement)
- func (l *PatchList) PushBack(v *Patch) *PatchElement
- func (l *PatchList) PushBackList(other *PatchList)
- func (l *PatchList) PushFront(v *Patch) *PatchElement
- func (l *PatchList) PushFrontList(other *PatchList)
- func (l *PatchList) Remove(e *PatchElement) *Patch
- type QueryRunner
- type RowKey
- type ScopeCache
- type SqlizerElement
- type SqlizerList
- func (l *SqlizerList) Back() *SqlizerElement
- func (l *SqlizerList) Front() *SqlizerElement
- func (l *SqlizerList) Init() *SqlizerList
- func (l *SqlizerList) InsertAfter(v squirrel.Sqlizer, mark *SqlizerElement) *SqlizerElement
- func (l *SqlizerList) InsertBefore(v squirrel.Sqlizer, mark *SqlizerElement) *SqlizerElement
- func (l *SqlizerList) Len() int
- func (l *SqlizerList) MoveAfter(e *SqlizerElement, mark *SqlizerElement)
- func (l *SqlizerList) MoveBefore(e *SqlizerElement, mark *SqlizerElement)
- func (l *SqlizerList) MoveToBack(e *SqlizerElement)
- func (l *SqlizerList) MoveToFront(e *SqlizerElement)
- func (l *SqlizerList) PushBack(v squirrel.Sqlizer) *SqlizerElement
- func (l *SqlizerList) PushBackList(other *SqlizerList)
- func (l *SqlizerList) PushFront(v squirrel.Sqlizer) *SqlizerElement
- func (l *SqlizerList) PushFrontList(other *SqlizerList)
- func (l *SqlizerList) Remove(e *SqlizerElement) squirrel.Sqlizer
- type StmtCacher
- func (pqr *StmtCacher) Close() error
- func (pqr *StmtCacher) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (pqr *StmtCacher) Prepare(query string) (*sql.Stmt, error)
- func (pqr *StmtCacher) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
- func (pqr *StmtCacher) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (pqr *StmtCacher) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (pqr *StmtCacher) StmtStats() StmtStats
- type StmtStats
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TxScope ¶
Example (Do) ¶
package main import ( "database/sql" "github.com/kamichidu/goen" _ "github.com/mattn/go-sqlite3" ) func main() { db, err := sql.Open("sqlite3", "./sqlite.db") if err != nil { panic(err) } defer db.Close() dbc := goen.NewDBContext("sqlite3", db) err = goen.TxScope(db.Begin()).Do(func(tx *sql.Tx) error { txc := dbc.UseTx(tx) // manipulate with txc txc.QueryRow("select 1") // return nil, will be called tx.Commit() by TxScope // otherwise, will be called tx.Rollback() return nil }) if err != nil { panic(err) } }
Output:
Example (FuncCall) ¶
package main import ( "database/sql" "github.com/kamichidu/goen" _ "github.com/mattn/go-sqlite3" ) func main() { db, err := sql.Open("sqlite3", "./sqlite.db") if err != nil { panic(err) } defer db.Close() dbc := goen.NewDBContext("sqlite3", db) err = goen.TxScope(db.Begin())(func(tx *sql.Tx) error { txc := dbc.UseTx(tx) // manipulate with txc txc.QueryRow("select 1") // return nil, will be called tx.Commit() by TxScope // otherwise, will be called tx.Rollback() return nil }) if err != nil { panic(err) } }
Output:
Types ¶
type BulkCompilerOptions ¶ added in v0.0.6
type BulkCompilerOptions struct { // MaxPatches limits values per bulk operations. // MaxPatches<=0 means unlimited. MaxPatches int }
func (*BulkCompilerOptions) Compile ¶ added in v0.0.6
func (c *BulkCompilerOptions) Compile(options *CompilerOptions) (sqlizers *SqlizerList)
type Cardinality ¶ added in v0.0.10
type Cardinality int
const ( CardinalityNone Cardinality = iota CardinalityOneToMany CardinalityManyToOne )
type CompilerHook ¶ added in v0.0.2
type CompilerHook interface { PostInsertBuilder(sqr.InsertBuilder) sqr.Sqlizer PostUpdateBuilder(sqr.UpdateBuilder) sqr.Sqlizer PostDeleteBuilder(sqr.DeleteBuilder) sqr.Sqlizer }
Example ¶
package main import ( "database/sql" "fmt" "strings" "github.com/Masterminds/squirrel" "github.com/kamichidu/goen" _ "github.com/kamichidu/goen/dialect/sqlite3" _ "github.com/mattn/go-sqlite3" ) type exampleHook struct { PostInsertBuilderHandler func(squirrel.InsertBuilder) squirrel.Sqlizer PostUpdateBuilderHandler func(squirrel.UpdateBuilder) squirrel.Sqlizer PostDeleteBuilderHandler func(squirrel.DeleteBuilder) squirrel.Sqlizer } func (v *exampleHook) PostInsertBuilder(stmt squirrel.InsertBuilder) squirrel.Sqlizer { if v.PostInsertBuilderHandler != nil { return v.PostInsertBuilderHandler(stmt) } else { return stmt } } func (v *exampleHook) PostUpdateBuilder(stmt squirrel.UpdateBuilder) squirrel.Sqlizer { if v.PostUpdateBuilderHandler != nil { return v.PostUpdateBuilderHandler(stmt) } else { return stmt } } func (v *exampleHook) PostDeleteBuilder(stmt squirrel.DeleteBuilder) squirrel.Sqlizer { if v.PostDeleteBuilderHandler != nil { return v.PostDeleteBuilderHandler(stmt) } else { return stmt } } func main() { db, err := sql.Open("sqlite3", "./sqlite.db") if err != nil { panic(err) } defer db.Close() ddl := []string{ `drop table if exists testing`, `create table testing (id integer primary key, name varchar(256))`, } if _, err := db.Exec(strings.Join(ddl, ";")); err != nil { panic(err) } dbc := goen.NewDBContext("sqlite3", db) dbc.Compiler = goen.CompilerWithHook(goen.DefaultCompiler, &exampleHook{ PostInsertBuilderHandler: func(stmt squirrel.InsertBuilder) squirrel.Sqlizer { fmt.Println("PostInsertBuilder: hello") return stmt }, PostUpdateBuilderHandler: func(stmt squirrel.UpdateBuilder) squirrel.Sqlizer { fmt.Println("PostUpdateBuilder: compiler") return stmt }, PostDeleteBuilderHandler: func(stmt squirrel.DeleteBuilder) squirrel.Sqlizer { fmt.Println("PostDeleteBuilder: hook") return stmt }, }) dbc.Patch(goen.InsertPatch("testing", []string{"name"}, []interface{}{"ExampleCompilerHook"})) dbc.Patch(goen.UpdatePatch("testing", []string{"name"}, []interface{}{"ExampleCompilerHook"}, nil)) dbc.Patch(goen.DeletePatch("testing", nil)) if err := dbc.SaveChanges(); err != nil { panic(err) } }
Output: PostInsertBuilder: hello PostUpdateBuilder: compiler PostDeleteBuilder: hook
type CompilerOptions ¶
type CompilerOptions struct { Dialect dialect.Dialect Patches *PatchList Hook CompilerHook }
type DBContext ¶
type DBContext struct { // This field is readonly. // Sets via NewDBContext(). DB *sql.DB // This field is readonly. // Sets via UseTx(); or nil. Tx *sql.Tx // The patch compiler. // This is used when need to compile patch to query. Compiler PatchCompiler // The logger for debugging. // This is used when DebugMode(true). Logger Logger // The depth limit to avoid circular Include work. // When this value is positive, Include works N-times. // When this value is negative, Include works unlimited. // When this value is 0, Include never works. // Default is 10. MaxIncludeDepth int // The runner for each query. // This field is indented to hold one of *sql.DB, *sql.Tx or *StmtCacher. QueryRunner QueryRunner // contains filtered or unexported fields }
DBContext holds *sql.DB (and *sql.Tx) with contextual values. goen is intended to work with *sql.DB (and *sql.Tx) via DBContext.
func NewDBContext ¶
NewDBContext creates DBContext with given dialectName and db.
func (*DBContext) CompilePatch ¶
func (dbc *DBContext) CompilePatch() *SqlizerList
CompilePatch compiles patches added by Patch() to SqlizerList. When this function is called, will clear internal patch buffer.
func (*DBContext) Include ¶
func (dbc *DBContext) Include(v interface{}, sc *ScopeCache, loader IncludeLoader) error
func (*DBContext) IncludeContext ¶
func (dbc *DBContext) IncludeContext(ctx context.Context, v interface{}, sc *ScopeCache, loader IncludeLoader) error
func (*DBContext) QueryContext ¶
func (*DBContext) QueryRowContext ¶
func (*DBContext) QueryRowSqlizer ¶
func (*DBContext) QueryRowSqlizerContext ¶
func (*DBContext) QuerySqlizer ¶
func (*DBContext) QuerySqlizerContext ¶
func (*DBContext) SaveChanges ¶
func (*DBContext) SaveChangesContext ¶
type IncludeBuffer ¶
func (*IncludeBuffer) AddRecords ¶
func (l *IncludeBuffer) AddRecords(records interface{})
type IncludeLoader ¶
type IncludeLoader interface {
Load(ctx context.Context, later *IncludeBuffer, sc *ScopeCache, records interface{}) error
}
type IncludeLoaderFunc ¶
type IncludeLoaderFunc func(context.Context, *IncludeBuffer, *ScopeCache, interface{}) error
func (IncludeLoaderFunc) Load ¶
func (fn IncludeLoaderFunc) Load(ctx context.Context, later *IncludeBuffer, sc *ScopeCache, records interface{}) error
type IncludeLoaderList ¶
type IncludeLoaderList []IncludeLoader
func (*IncludeLoaderList) Append ¶
func (list *IncludeLoaderList) Append(v ...IncludeLoader)
func (IncludeLoaderList) Load ¶
func (list IncludeLoaderList) Load(ctx context.Context, later *IncludeBuffer, sc *ScopeCache, records interface{}) error
type LoggerFunc ¶ added in v0.0.5
type LoggerFunc func(...interface{})
func (LoggerFunc) Print ¶ added in v0.0.5
func (fn LoggerFunc) Print(args ...interface{})
func (LoggerFunc) Printf ¶ added in v0.0.5
func (fn LoggerFunc) Printf(format string, args ...interface{})
type MetaColumn ¶ added in v0.0.1
type MetaColumn interface { // Field gets go struct field associated with this column. Field() reflect.StructField // OmitEmpty indicates this column allowing to omit column specifier on a insert statement. OmitEmpty() bool // PartOfPrimaryKey indicates this column is part of primary key of the table. PartOfPrimaryKey() bool // ColumnName gets this column name. ColumnName() string }
MetaColumn represents a column meta info.
type MetaSchema ¶
type MetaSchema interface { // Register adds given object type to this MetaSchema. Register(entity interface{}) // Compute computes meta schemata for registered entities. Compute() // LoadOf gets meta schema of table that associated with given entity. LoadOf(entity interface{}) MetaTable // KeyStringFromRowKey gets identity string for given RowKey. KeyStringFromRowKey(RowKey) string // PrimaryKeyOf gets RowKey that represents given entity. PrimaryKeyOf(entity interface{}) RowKey // ReferenceKeysOf gets RowKeys that references to entity by other entities. ReferenceKeysOf(entity interface{}) []RowKey // OneToManyReferenceKeysOf gets RowKeysone that references to entity by other entities with one to many cardinal. OneToManyReferenceKeysOf(entity interface{}) []RowKey // ManyToOneReferenceKeysOf gets RowKeysone that references to entity by other entities with many to one cardinal. ManyToOneReferenceKeysOf(entity interface{}) []RowKey // InsertPatchOf gets a patch that represents insert statement. InsertPatchOf(entity interface{}) *Patch // UpdatePatchOf gets a patch that represents update statement. UpdatePatchOf(entity interface{}) *Patch // DeletePatchOf gets a patch that represents delete statement. DeletePatchOf(entity interface{}) *Patch }
MetaSchema manages meta schemata computed by struct (tags). Provide some utility functions for using with DBContext.
func NewMetaSchema ¶ added in v0.0.1
func NewMetaSchema() MetaSchema
NewMetaSchema creates new MetaSchema object.
type MetaTable ¶ added in v0.0.1
type MetaTable interface { // Type gets go struct type associated with this table. Type() reflect.Type // TableName gets a table name. TableName() string // PrimaryKey gets primary key meta columns. PrimaryKey() []MetaColumn // ReferenceKeys gets all reference meta columns by other entities. ReferenceKeys() [][]MetaColumn // OneToManyReferenceKeys gets all one to many reference meta columns by other entities. OneToManyReferenceKeys() [][]MetaColumn // ManyToOneReferenceKeys gets all many to one reference meta columns by other entities. ManyToOneReferenceKeys() [][]MetaColumn // Columns gets all meta columns of this table. Columns() []MetaColumn }
MetaTable represents a table meta info.
type Patch ¶
type Patch struct { Kind PatchKind TableName string RowKey RowKey Columns []string Values []interface{} }
func DeletePatch ¶
func InsertPatch ¶
type PatchCompiler ¶
type PatchCompiler interface {
Compile(*CompilerOptions) *SqlizerList
}
var ( DefaultCompiler PatchCompiler = &defaultCompiler{} BulkCompiler PatchCompiler = &BulkCompilerOptions{} )
func CompilerWithHook ¶ added in v0.0.2
func CompilerWithHook(c PatchCompiler, v CompilerHook) PatchCompiler
type PatchCompilerFunc ¶
type PatchCompilerFunc func(*CompilerOptions) *SqlizerList
func (PatchCompilerFunc) Compile ¶
func (fn PatchCompilerFunc) Compile(opts *CompilerOptions) (sqlizers *SqlizerList)
type PatchElement ¶
type PatchElement struct {
// contains filtered or unexported fields
}
PatchElement is typed version of list.Element
func (*PatchElement) GetValue ¶
func (e *PatchElement) GetValue() *Patch
GetValue gets the value stored with this element.
func (*PatchElement) Next ¶
func (e *PatchElement) Next() *PatchElement
Next returns the next list element or nil.
func (*PatchElement) Prev ¶
func (e *PatchElement) Prev() *PatchElement
Prev returns the previous list element or nil.
func (*PatchElement) SetValue ¶
func (e *PatchElement) SetValue(v *Patch)
SetValue sets value with this element.
type PatchList ¶
PatchList is typed version of list.List
func NewPatchList ¶
func NewPatchList() *PatchList
func (*PatchList) Back ¶
func (l *PatchList) Back() *PatchElement
Back is typed version of (*list.List).Back
func (*PatchList) Front ¶
func (l *PatchList) Front() *PatchElement
Front is typed version of (*list.List).Front
func (*PatchList) InsertAfter ¶
func (l *PatchList) InsertAfter(v *Patch, mark *PatchElement) *PatchElement
InsertAfter is typed version of (*list.List).InsertAfter
func (*PatchList) InsertBefore ¶
func (l *PatchList) InsertBefore(v *Patch, mark *PatchElement) *PatchElement
InsertBefore is typed version of (*list.List).InsertBefore
func (*PatchList) MoveAfter ¶
func (l *PatchList) MoveAfter(e *PatchElement, mark *PatchElement)
MoveAfter is typed version of (*list.List).MoveAfter
func (*PatchList) MoveBefore ¶
func (l *PatchList) MoveBefore(e *PatchElement, mark *PatchElement)
MoveBefore is typed version of (*list.List).MoveBefore
func (*PatchList) MoveToBack ¶
func (l *PatchList) MoveToBack(e *PatchElement)
MoveToBack is typed version of (*list.List).MoveToBack
func (*PatchList) MoveToFront ¶
func (l *PatchList) MoveToFront(e *PatchElement)
MoveToFront is typed version of (*list.List).MoveToFront
func (*PatchList) PushBack ¶
func (l *PatchList) PushBack(v *Patch) *PatchElement
PushBack is typed version of (*list.List).PushBack
func (*PatchList) PushBackList ¶
PushBackList is typed version of (*list.List).PushBackList
func (*PatchList) PushFront ¶
func (l *PatchList) PushFront(v *Patch) *PatchElement
PushFront is typed version of (*list.List).PushFront
func (*PatchList) PushFrontList ¶
PushFrontList is typed version of (*list.List).PushFrontList
func (*PatchList) Remove ¶
func (l *PatchList) Remove(e *PatchElement) *Patch
Remove is typed version of (*list.List).Remove
type QueryRunner ¶
type QueryRunner interface { ExecContext(context.Context, string, ...interface{}) (sql.Result, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) }
QueryRunner ...
type ScopeCache ¶
type ScopeCache struct { Meta MetaSchema // contains filtered or unexported fields }
func NewScopeCache ¶
func NewScopeCache(meta MetaSchema) *ScopeCache
func (*ScopeCache) AddObject ¶
func (sc *ScopeCache) AddObject(v interface{})
func (*ScopeCache) GetObject ¶
func (sc *ScopeCache) GetObject(cardinality Cardinality, rowKey RowKey) interface{}
GetObject gets stored object with given cardinality
func (*ScopeCache) HasObject ¶
func (sc *ScopeCache) HasObject(cardinality Cardinality, rowKey RowKey) bool
HasObject checks stored object with given cardinality is exists or not.
func (*ScopeCache) RemoveObject ¶
func (sc *ScopeCache) RemoveObject(v interface{})
type SqlizerElement ¶
type SqlizerElement struct {
// contains filtered or unexported fields
}
SqlizerElement is typed version of list.Element
func (*SqlizerElement) GetValue ¶
func (e *SqlizerElement) GetValue() squirrel.Sqlizer
GetValue gets the value stored with this element.
func (*SqlizerElement) Next ¶
func (e *SqlizerElement) Next() *SqlizerElement
Next returns the next list element or nil.
func (*SqlizerElement) Prev ¶
func (e *SqlizerElement) Prev() *SqlizerElement
Prev returns the previous list element or nil.
func (*SqlizerElement) SetValue ¶
func (e *SqlizerElement) SetValue(v squirrel.Sqlizer)
SetValue sets value with this element.
type SqlizerList ¶
SqlizerList is typed version of list.List
func NewSqlizerList ¶
func NewSqlizerList() *SqlizerList
func (*SqlizerList) Back ¶
func (l *SqlizerList) Back() *SqlizerElement
Back is typed version of (*list.List).Back
func (*SqlizerList) Front ¶
func (l *SqlizerList) Front() *SqlizerElement
Front is typed version of (*list.List).Front
func (*SqlizerList) Init ¶
func (l *SqlizerList) Init() *SqlizerList
Init is typed version of (*list.List).Init
func (*SqlizerList) InsertAfter ¶
func (l *SqlizerList) InsertAfter(v squirrel.Sqlizer, mark *SqlizerElement) *SqlizerElement
InsertAfter is typed version of (*list.List).InsertAfter
func (*SqlizerList) InsertBefore ¶
func (l *SqlizerList) InsertBefore(v squirrel.Sqlizer, mark *SqlizerElement) *SqlizerElement
InsertBefore is typed version of (*list.List).InsertBefore
func (*SqlizerList) MoveAfter ¶
func (l *SqlizerList) MoveAfter(e *SqlizerElement, mark *SqlizerElement)
MoveAfter is typed version of (*list.List).MoveAfter
func (*SqlizerList) MoveBefore ¶
func (l *SqlizerList) MoveBefore(e *SqlizerElement, mark *SqlizerElement)
MoveBefore is typed version of (*list.List).MoveBefore
func (*SqlizerList) MoveToBack ¶
func (l *SqlizerList) MoveToBack(e *SqlizerElement)
MoveToBack is typed version of (*list.List).MoveToBack
func (*SqlizerList) MoveToFront ¶
func (l *SqlizerList) MoveToFront(e *SqlizerElement)
MoveToFront is typed version of (*list.List).MoveToFront
func (*SqlizerList) PushBack ¶
func (l *SqlizerList) PushBack(v squirrel.Sqlizer) *SqlizerElement
PushBack is typed version of (*list.List).PushBack
func (*SqlizerList) PushBackList ¶
func (l *SqlizerList) PushBackList(other *SqlizerList)
PushBackList is typed version of (*list.List).PushBackList
func (*SqlizerList) PushFront ¶
func (l *SqlizerList) PushFront(v squirrel.Sqlizer) *SqlizerElement
PushFront is typed version of (*list.List).PushFront
func (*SqlizerList) PushFrontList ¶
func (l *SqlizerList) PushFrontList(other *SqlizerList)
PushFrontList is typed version of (*list.List).PushFrontList
func (*SqlizerList) Remove ¶
func (l *SqlizerList) Remove(e *SqlizerElement) squirrel.Sqlizer
Remove is typed version of (*list.List).Remove
type StmtCacher ¶
type StmtCacher struct {
// contains filtered or unexported fields
}
StmtCacher implements QueryRunner. It caches prepared statements for executing or querying.
func NewStmtCacher ¶
func NewStmtCacher(prep sqr.PreparerContext) *StmtCacher
NewStmtCacher returns new StmtCacher with given prep.
func (*StmtCacher) Close ¶
func (pqr *StmtCacher) Close() error
Close closes and removes all cached prepared statements.
func (*StmtCacher) ExecContext ¶
func (pqr *StmtCacher) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext executes given query with args via prepared statement.
func (*StmtCacher) Prepare ¶
func (pqr *StmtCacher) Prepare(query string) (*sql.Stmt, error)
Prepare is only for implements squirrel.PreparerContext. DO NOT USE THIS.
func (*StmtCacher) PrepareContext ¶
PrepareContext returns new or cached prepared statement.
func (*StmtCacher) QueryContext ¶
func (pqr *StmtCacher) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContext queries by given query with args via prepared statement.
func (*StmtCacher) QueryRowContext ¶
func (pqr *StmtCacher) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
QueryRowContext queries a row by given query with args via prepared statement.
func (*StmtCacher) StmtStats ¶
func (pqr *StmtCacher) StmtStats() StmtStats
StmtStats returns statistics values.