bumps uptrace/bun dependencies to v1.2.6 (#3569)

This commit is contained in:
kim 2024-11-25 15:42:37 +00:00 committed by GitHub
commit 3fceb5fc1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
68 changed files with 6517 additions and 194 deletions

View file

@ -15,6 +15,7 @@ import (
type UpdateQuery struct {
whereBaseQuery
orderLimitOffsetQuery
returningQuery
customValueQuery
setQuery
@ -53,10 +54,12 @@ func (q *UpdateQuery) Err(err error) *UpdateQuery {
return q
}
// Apply calls the fn passing the SelectQuery as an argument.
func (q *UpdateQuery) Apply(fn func(*UpdateQuery) *UpdateQuery) *UpdateQuery {
if fn != nil {
return fn(q)
// Apply calls each function in fns, passing the UpdateQuery as an argument.
func (q *UpdateQuery) Apply(fns ...func(*UpdateQuery) *UpdateQuery) *UpdateQuery {
for _, fn := range fns {
if fn != nil {
q = fn(q)
}
}
return q
}
@ -200,6 +203,34 @@ func (q *UpdateQuery) WhereAllWithDeleted() *UpdateQuery {
return q
}
// ------------------------------------------------------------------------------
func (q *UpdateQuery) Order(orders ...string) *UpdateQuery {
if !q.hasFeature(feature.UpdateOrderLimit) {
q.err = errors.New("bun: order is not supported for current dialect")
return q
}
q.addOrder(orders...)
return q
}
func (q *UpdateQuery) OrderExpr(query string, args ...interface{}) *UpdateQuery {
if !q.hasFeature(feature.UpdateOrderLimit) {
q.err = errors.New("bun: order is not supported for current dialect")
return q
}
q.addOrderExpr(query, args...)
return q
}
func (q *UpdateQuery) Limit(n int) *UpdateQuery {
if !q.hasFeature(feature.UpdateOrderLimit) {
q.err = errors.New("bun: limit is not supported for current dialect")
return q
}
q.setLimit(n)
return q
}
//------------------------------------------------------------------------------
// Returning adds a RETURNING clause to the query.
@ -278,6 +309,16 @@ func (q *UpdateQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, e
return nil, err
}
b, err = q.appendOrder(fmter, b)
if err != nil {
return nil, err
}
b, err = q.appendLimitOffset(fmter, b)
if err != nil {
return nil, err
}
if q.hasFeature(feature.Returning) && q.hasReturning() {
b = append(b, " RETURNING "...)
b, err = q.appendReturning(fmter, b)