-
Notifications
You must be signed in to change notification settings - Fork 3
/
mysql.go
43 lines (33 loc) · 931 Bytes
/
mysql.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
package querysql
import (
"fmt"
)
type MySQL struct{}
func (m MySQL) Mark() string {
return "?"
}
func (m MySQL) IsJSON(name string) (string, bool) {
return name, false
}
func (m MySQL) Contains(v string, isJSON bool) string {
return fmt.Sprintf("INSTR(%s, ?) > 0", v)
}
func (m MySQL) NotContains(v string, isJSON bool) string {
return fmt.Sprintf("INSTR(%s, ?) = 0", v)
}
func (m MySQL) BeginsWith(v string, isJSON bool) string {
search := "CONCAT(?, '%')"
return fmt.Sprintf("%s LIKE %s", v, search)
}
func (m MySQL) NotBeginsWith(v string, isJSON bool) string {
search := "CONCAT(?, '%')"
return fmt.Sprintf("%s NOT LIKE %s", v, search)
}
func (m MySQL) EndsWith(v string, isJSON bool) string {
search := "CONCAT('%', ?)"
return fmt.Sprintf("%s LIKE %s", v, search)
}
func (m MySQL) NotEndsWith(v string, isJSON bool) string {
search := "CONCAT('%', ?)"
return fmt.Sprintf("%s NOT LIKE %s", v, search)
}