MCPcopy Index your code
hub / github.com/ent/ent / ResolveWithNewValues

Function ResolveWithNewValues

dialect/sql/builder.go:327–335  ·  view source on GitHub ↗

ResolveWithNewValues updates columns using the new values proposed for insertion using the special EXCLUDED/VALUES table. sql.Insert("users"). Columns("id", "name"). Values(1, "Mashraki"). OnConflict( sql.ConflictColumns("id"), sql.ResolveWithNewValues() ) // Output: // MySQL: INS

()

Source from the content-addressed store, hash-verified

325// // MySQL: INSERT INTO `users` (`id`, `name`) VALUES(1, 'Mashraki) ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`),
326// // PostgreSQL: INSERT INTO "users" ("id") VALUES(1) ON CONFLICT ("id") DO UPDATE SET "id" = "excluded"."id, "name" = "excluded"."name"
327func ResolveWithNewValues() ConflictOption {
328 return func(c *conflict) {
329 c.action.update = append(c.action.update, func(u *UpdateSet) {
330 for _, c := range u.columns {
331 u.SetExcluded(c)
332 }
333 })
334 }
335}
336
337// ResolveWith allows setting a custom function to set the `UPDATE` clause.
338//

Callers 15

UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92
UpdateNewValuesMethod · 0.92

Calls 1

SetExcludedMethod · 0.80

Tested by 2

TestCreateNodeFunction · 0.74
TestInsert_OnConflictFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…