MCPcopy
hub / github.com/go-gorm/gorm / getInstance

Method getInstance

gorm.go:448–475  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

446}
447
448func (db *DB) getInstance() *DB {
449 if db.clone > 0 {
450 tx := &DB{Config: db.Config, Error: db.Error}
451
452 if db.clone == 1 {
453 // clone with new statement
454 tx.Statement = &Statement{
455 DB: tx,
456 ConnPool: db.Statement.ConnPool,
457 Context: db.Statement.Context,
458 Clauses: map[string]clause.Clause{},
459 Vars: make([]interface{}, 0, 8),
460 SkipHooks: db.Statement.SkipHooks,
461 }
462 if db.Config.PropagateUnscoped {
463 tx.Statement.Unscoped = db.Statement.Unscoped
464 }
465 } else {
466 // with clone statement
467 tx.Statement = db.Statement.clone()
468 tx.Statement.DB = tx
469 }
470
471 return tx
472 }
473
474 return db
475}
476
477// Expr returns clause.Expr, which can be used to pass SQL expression as params
478func Expr(expr string, args ...interface{}) clause.Expr {

Callers 15

ModelMethod · 0.95
ClausesMethod · 0.95
TableMethod · 0.95
DistinctMethod · 0.95
SelectMethod · 0.95
OmitMethod · 0.95
MapColumnsMethod · 0.95
WhereMethod · 0.95
NotMethod · 0.95
OrMethod · 0.95
GroupMethod · 0.95
HavingMethod · 0.95

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected