MCPcopy
hub / github.com/ent/ent / Arg

Method Arg

dialect/sql/builder.go:3162–3187  ·  view source on GitHub ↗

Arg appends an input argument to the builder.

(a any)

Source from the content-addressed store, hash-verified

3160
3161// Arg appends an input argument to the builder.
3162func (b *Builder) Arg(a any) *Builder {
3163 switch v := a.(type) {
3164 case nil:
3165 b.WriteString("NULL")
3166 return b
3167 case *raw:
3168 b.WriteString(v.s)
3169 return b
3170 case Querier:
3171 b.Join(v)
3172 return b
3173 }
3174 // Default placeholder param (MySQL and SQLite).
3175 format := "?"
3176 if b.postgres() {
3177 // Postgres' arguments are referenced using the syntax $n.
3178 // $1 refers to the 1st argument, $2 to the 2nd, and so on.
3179 format = "$" + strconv.Itoa(b.total+1)
3180 }
3181 if f, ok := a.(ParamFormatter); ok {
3182 format = f.FormatParam(format, &StmtInfo{
3183 Dialect: b.dialect,
3184 })
3185 }
3186 return b.Argf(format, a)
3187}
3188
3189// Args appends a list of arguments to the builder.
3190func (b *Builder) Args(a ...any) *Builder {

Callers 15

ArgsMethod · 0.95
SelectFunction · 0.80
NicknameSearchFunction · 0.80
NameGlobFunction · 0.80
TestBuilderFunction · 0.80
TestSelector_OrderByExprFunction · 0.80
TestSelector_SelectExprFunction · 0.80
TestMultipleFromFunction · 0.80
AddMethod · 0.80
writeSetterMethod · 0.80

Calls 5

WriteStringMethod · 0.95
JoinMethod · 0.95
postgresMethod · 0.95
ArgfMethod · 0.95
FormatParamMethod · 0.65

Tested by 8

SelectFunction · 0.64
NicknameSearchFunction · 0.64
TestBuilderFunction · 0.64
TestSelector_OrderByExprFunction · 0.64
TestSelector_SelectExprFunction · 0.64
TestMultipleFromFunction · 0.64