-
Notifications
You must be signed in to change notification settings - Fork 0
/
field_bool.go
99 lines (80 loc) · 2.01 KB
/
field_bool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package rapier
import "gorm.io/gorm/clause"
// Bool boolean type field
type Bool Field
// NewBool new bool field.
func NewBool(table, column string, opts ...Option) Bool {
return Bool{
expr: expr{
col: intoClauseColumn(table, column, opts...),
},
}
}
// IfNull use IFNULL(expr,?)
func (field Bool) IfNull(value bool) Expr {
return field.innerIfNull(value)
}
// NullIf use NULLIF(expr,?)
func (field Bool) NullIf(value bool) Expr {
return field.innerNullIf(value)
}
// Eq equal to, use expr = ?
func (field Bool) Eq(value bool) Expr {
return field.innerEq(value)
}
// Neq not equal to, use expr <> ?
func (field Bool) Neq(value bool) Expr {
return field.innerNeq(value)
}
// FindInSet use FIND_IN_SET(expr, ?)
func (field Bool) FindInSet(targetList string) Expr {
return field.innerFindInSet(targetList)
}
// Is use expr = ?
func (field Bool) Is(value bool) Expr {
return field.Eq(value)
}
// Not use NOT expr
func (field Bool) Not() Expr {
return expr{
col: field.col,
e: clause.Expr{SQL: "NOT ?", Vars: []any{field.RawExpr()}},
buildOpts: field.buildOpts,
}
}
// Xor use expr XOR ?
func (field Bool) Xor(value bool) Expr {
return Bool{field.innerXor(value)}
}
// And use expr AND ?
func (field Bool) And(value bool) Expr {
return Bool{field.innerAnd(value)}
}
// Or use expr OR ?
func (field Bool) Or(value bool) Expr {
return Bool{field.innerOr(value)}
}
// BitXor use expr expr^?
func (field Bool) BitXor(value bool) Expr {
return Bool{field.innerBitXor(value)}
}
// BitAnd use expr expr&?
func (field Bool) BitAnd(value bool) Expr {
return Bool{field.innerBitAnd(value)}
}
// BitOr use expr expr|?
func (field Bool) BitOr(value bool) Expr {
return Bool{field.innerBitOr(value)}
}
// Value set value
func (field Bool) Value(value bool) AssignExpr {
return field.value(value)
}
// Value set value use pointer
func (field Bool) ValuePointer(value *bool) AssignExpr {
return field.value(value)
}
// ValueZero set value zero
func (field Bool) ValueZero() AssignExpr {
return field.value(false)
}