| 446 | } |
| 447 | |
| 448 | func (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 |
| 478 | func Expr(expr string, args ...interface{}) clause.Expr { |