chore: ⬆️ updated deps
This commit is contained in:
+1
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/uptrace/bun/dialect"
|
||||
)
|
||||
|
||||
// Deprecated: Use List or Tuple instead.
|
||||
func In(slice any) QueryAppender {
|
||||
v := reflect.ValueOf(slice)
|
||||
if v.Kind() != reflect.Slice {
|
||||
|
||||
+12
-1
@@ -87,7 +87,7 @@ func (f *Field) HasZeroValue(v reflect.Value) bool {
|
||||
}
|
||||
|
||||
for _, index := range f.Index {
|
||||
if v.Kind() == reflect.Ptr {
|
||||
if v.Kind() == reflect.Pointer {
|
||||
if v.IsNil() {
|
||||
return true
|
||||
}
|
||||
@@ -99,12 +99,23 @@ func (f *Field) HasZeroValue(v reflect.Value) bool {
|
||||
}
|
||||
|
||||
func (f *Field) AppendValue(gen QueryGen, b []byte, strct reflect.Value) []byte {
|
||||
return f.appendValue(gen, b, strct, false)
|
||||
}
|
||||
|
||||
func (f *Field) AppendValueOrDefault(gen QueryGen, b []byte, strct reflect.Value) []byte {
|
||||
return f.appendValue(gen, b, strct, true)
|
||||
}
|
||||
|
||||
func (f *Field) appendValue(gen QueryGen, b []byte, strct reflect.Value, defaultPlaceholder bool) []byte {
|
||||
fv, ok := fieldByIndex(strct, f.Index)
|
||||
if !ok {
|
||||
return dialect.AppendNull(b)
|
||||
}
|
||||
|
||||
if (f.IsPtr && fv.IsNil()) || (f.NullZero && f.IsZero(fv)) {
|
||||
if defaultPlaceholder {
|
||||
return append(b, "DEFAULT"...)
|
||||
}
|
||||
return dialect.AppendNull(b)
|
||||
}
|
||||
if f.Append == nil {
|
||||
|
||||
+2
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Relation type constants define the possible types of table relationships.
|
||||
const (
|
||||
InvalidRelation = iota
|
||||
HasOneRelation
|
||||
@@ -12,6 +13,7 @@ const (
|
||||
ManyToManyRelation
|
||||
)
|
||||
|
||||
// Relation describes how two tables are related (has-one, belongs-to, has-many, or many-to-many).
|
||||
type Relation struct {
|
||||
Type int
|
||||
Field *Field // Has the bun tag defining this relation.
|
||||
|
||||
+5
@@ -7,10 +7,12 @@ import (
|
||||
"github.com/uptrace/bun/internal"
|
||||
)
|
||||
|
||||
// QueryAppender is implemented by types that can append themselves to a SQL query.
|
||||
type QueryAppender interface {
|
||||
AppendQuery(gen QueryGen, b []byte) ([]byte, error)
|
||||
}
|
||||
|
||||
// ColumnsAppender is implemented by types that can append column definitions to a SQL query.
|
||||
type ColumnsAppender interface {
|
||||
AppendColumns(gen QueryGen, b []byte) ([]byte, error)
|
||||
}
|
||||
@@ -51,6 +53,7 @@ func (s Ident) AppendQuery(gen QueryGen, b []byte) ([]byte, error) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// QueryWithArgs is a query string paired with its arguments.
|
||||
// NOTE: It should not be modified after creation.
|
||||
type QueryWithArgs struct {
|
||||
Query string
|
||||
@@ -88,6 +91,7 @@ func (q QueryWithArgs) AppendQuery(gen QueryGen, b []byte) ([]byte, error) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Order represents a SQL sort direction.
|
||||
type Order string
|
||||
|
||||
const (
|
||||
@@ -120,6 +124,7 @@ func AppendOrder(b []byte, sortDir Order) []byte {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// QueryWithSep is a QueryWithArgs with an additional separator.
|
||||
type QueryWithSep struct {
|
||||
QueryWithArgs
|
||||
Sep string
|
||||
|
||||
+1
@@ -50,6 +50,7 @@ func isZero(v any) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// IsZeroerFunc reports whether a reflect.Value is a zero value.
|
||||
type IsZeroerFunc func(reflect.Value) bool
|
||||
|
||||
func zeroChecker(typ reflect.Type) IsZeroerFunc {
|
||||
|
||||
Reference in New Issue
Block a user