MCPcopy
hub / github.com/ent/ent / SetExcluded

Method SetExcluded

dialect/sql/builder.go:422–433  ·  view source on GitHub ↗

SetExcluded sets the column name to its EXCLUDED/VALUES value. For example, "c" = "excluded"."c", or `c` = VALUES(`c`).

(name string)

Source from the content-addressed store, hash-verified

420// SetExcluded sets the column name to its EXCLUDED/VALUES value.
421// For example, "c" = "excluded"."c", or `c` = VALUES(`c`).
422func (u *UpdateSet) SetExcluded(name string) *UpdateSet {
423 switch u.UpdateBuilder.Dialect() {
424 case dialect.MySQL:
425 u.UpdateBuilder.Set(name, ExprFunc(func(b *Builder) {
426 b.WriteString("VALUES(").Ident(name).WriteByte(')')
427 }))
428 default:
429 t := Dialect(u.UpdateBuilder.dialect).Table("excluded")
430 u.UpdateBuilder.Set(name, Expr(t.C(name)))
431 }
432 return u
433}
434
435// Query returns query representation of an `INSERT INTO` statement.
436func (i *InsertBuilder) Query() (string, []any) {

Callers 15

UpdateUpdateTimeMethod · 0.80
UpdateSetIDMethod · 0.80
UpdateSizeMethod · 0.80
UpdateNameMethod · 0.80
UpdateUserMethod · 0.80
UpdateGroupMethod · 0.80
UpdateOpMethod · 0.80
UpdateFieldIDMethod · 0.80
UpdateCreateTimeMethod · 0.80
UpdateTextMethod · 0.80
UpdateNameMethod · 0.80
UpdateTypeMethod · 0.80

Calls 10

ExprFuncFunction · 0.85
DialectFunction · 0.85
WriteByteMethod · 0.80
IdentMethod · 0.80
WriteStringMethod · 0.80
ExprFunction · 0.70
DialectMethod · 0.65
CMethod · 0.65
SetMethod · 0.45
TableMethod · 0.45

Tested by 1

TestInsert_OnConflictFunction · 0.64