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

Method clone

statement.go:529–581  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

527}
528
529func (stmt *Statement) clone() *Statement {
530 newStmt := &Statement{
531 TableExpr: stmt.TableExpr,
532 Table: stmt.Table,
533 Model: stmt.Model,
534 Unscoped: stmt.Unscoped,
535 Dest: stmt.Dest,
536 ReflectValue: stmt.ReflectValue,
537 Clauses: map[string]clause.Clause{},
538 Distinct: stmt.Distinct,
539 Selects: stmt.Selects,
540 Omits: stmt.Omits,
541 ColumnMapping: stmt.ColumnMapping,
542 Preloads: map[string][]interface{}{},
543 ConnPool: stmt.ConnPool,
544 Schema: stmt.Schema,
545 Context: stmt.Context,
546 RaiseErrorOnNotFound: stmt.RaiseErrorOnNotFound,
547 SkipHooks: stmt.SkipHooks,
548 Result: stmt.Result,
549 }
550
551 if stmt.SQL.Len() > 0 {
552 newStmt.SQL.WriteString(stmt.SQL.String())
553 newStmt.Vars = make([]interface{}, 0, len(stmt.Vars))
554 newStmt.Vars = append(newStmt.Vars, stmt.Vars...)
555 }
556
557 for k, c := range stmt.Clauses {
558 newStmt.Clauses[k] = c
559 }
560
561 for k, p := range stmt.Preloads {
562 newStmt.Preloads[k] = p
563 }
564
565 if len(stmt.Joins) > 0 {
566 newStmt.Joins = make([]join, len(stmt.Joins))
567 copy(newStmt.Joins, stmt.Joins)
568 }
569
570 if len(stmt.scopes) > 0 {
571 newStmt.scopes = make([]func(*DB) *DB, len(stmt.scopes))
572 copy(newStmt.scopes, stmt.scopes)
573 }
574
575 stmt.Settings.Range(func(k, v interface{}) bool {
576 newStmt.Settings.Store(k, v)
577 return true
578 })
579
580 return newStmt
581}
582
583// SetColumn set column's value
584//

Callers 3

SessionMethod · 0.80
getInstanceMethod · 0.80
TestWhereCloneCorruptionFunction · 0.80

Calls 3

LenMethod · 0.80
WriteStringMethod · 0.65
StringMethod · 0.45

Tested by 1

TestWhereCloneCorruptionFunction · 0.64