-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_condition.go
76 lines (60 loc) · 2.16 KB
/
sql_condition.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
package sql
import (
"github.com/go-xe2/x/xf/ef/xq/xqcomm"
"github.com/go-xe2/x/xf/ef/xqi"
)
func Where(items ...xqi.SqlLogic) xqi.SqlCondition {
return And(items...)
}
func On(items ...xqi.SqlLogic) xqi.SqlCondition {
return And(items...)
}
func And(items ...xqi.SqlLogic) xqi.SqlCondition {
return xqcomm.NewSqlCondition(xqi.SqlConditionAndLogic).And(items...)
}
func Or(items ...xqi.SqlLogic) xqi.SqlCondition {
var result xqi.SqlCondition = xqcomm.NewSqlCondition(xqi.SqlConditionOrLogic)
for _, v := range items {
result = result.Or(v)
}
return result
//return xqcomm.NewSqlCondition(xqi.SqlConditionOrLogic).And(items...)
}
func Xor(items ...xqi.SqlLogic) xqi.SqlCondition {
var result xqi.SqlCondition = xqcomm.NewSqlCondition(xqi.SqlConditionOrLogic)
for _, v := range items {
result = result.Xor(v)
}
return result
//return xqcomm.NewSqlCondition(xqi.SqlConditionXorLogic).And(items...)
}
func Eq(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareEQType)
}
func Neq(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareNEQType)
}
func Gt(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareEQType)
}
func Gte(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareGTEType)
}
func Lt(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareLTType)
}
func Lte(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareLTEType)
}
func Like(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareLKType)
}
func NotLike(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareNLKType)
}
func In(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareINType)
}
func NotIn(exp1, exp2 interface{}) xqi.SqlConditionItem {
return xqcomm.NewSqlConditionItem(exp1, exp2, xqi.SqlCompareNINType)
}