/
githubmirror
/
sqlc
Обзор
Документация
Войти
/
githubmirror
/
sqlc
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/sql/ast/on_duplicate_key_update.go
37 строк
817 B
Kyle Gray
refactor(ast): rename Formatter interface to Dialect (#4208)
01 дек 2025, 04:49
Не верифицирован
01 дек 2025, 04:49
ebd32cf
Код
Авторство
О чём код?
package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" // OnDuplicateKeyUpdate represents MySQL's ON DUPLICATE KEY UPDATE clause type OnDuplicateKeyUpdate struct { // TargetList contains the assignments (column = value pairs) TargetList *List Location int } func (n *OnDuplicateKeyUpdate) Pos() int { return n.Location } func (n *OnDuplicateKeyUpdate) Format(buf *TrackedBuffer, d format.Dialect) { if n == nil { return } buf.WriteString("ON DUPLICATE KEY UPDATE ") if n.TargetList != nil { for i, item := range n.TargetList.Items { if i > 0 { buf.WriteString(", ") } if rt, ok := item.(*ResTarget); ok { if rt.Name != nil { buf.WriteString(*rt.Name) } buf.WriteString(" = ") buf.astFormat(rt.Val, d) } else { buf.astFormat(item, d) } } } }