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

Method Build

clause/expression.go:28–58  ·  view source on GitHub ↗

Build build raw expression

(builder Builder)

Source from the content-addressed store, hash-verified

26
27// Build build raw expression
28func (expr Expr) Build(builder Builder) {
29 var (
30 afterParenthesis bool
31 idx int
32 )
33
34 for _, v := range []byte(expr.SQL) {
35 if v == '?' && len(expr.Vars) > idx {
36 if afterParenthesis || expr.WithoutParentheses {
37 processValue(builder, expr.Vars[idx])
38 } else {
39 builder.AddVar(builder, expr.Vars[idx])
40 }
41
42 idx++
43 } else {
44 if v == '(' {
45 afterParenthesis = true
46 } else {
47 afterParenthesis = false
48 }
49 builder.WriteByte(v)
50 }
51 }
52
53 if idx < len(expr.Vars) {
54 for _, v := range expr.Vars[idx:] {
55 builder.AddVar(builder, sql.NamedArg{Value: v})
56 }
57 }
58}
59
60// NamedExpr raw expression for named expr
61type NamedExpr struct {

Callers

nothing calls this directly

Calls 3

processValueFunction · 0.85
AddVarMethod · 0.65
WriteByteMethod · 0.65

Tested by

no test coverage detected