-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcolumn.go
80 lines (63 loc) · 2.06 KB
/
column.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
package postgres
import (
"fmt"
"github.com/aodin/sol"
)
const (
Contains = "@>"
ContainedBy = "<@"
Overlap = "&&"
StrictlyLeftOf = "<<"
StrictlyRightOf = ">>"
DoesNotExtendToTheRightOf = "&<"
DoesNotExtendToTheLeftOf = "&>"
IsAdjacentTo = "-|-"
Union = "+"
Intersection = "*"
Difference = "-"
)
// ColumnElem is the postgres dialect's implementation of a SQL column
type ColumnElem struct {
sol.ColumnElem
}
var _ sol.Columnar = ColumnElem{}
func (col ColumnElem) operator(op string, param interface{}) sol.BinaryClause {
return sol.BinaryClause{
Pre: col,
Post: &sol.Parameter{Value: param},
Sep: fmt.Sprintf(" %s ", op),
}
}
func (col ColumnElem) Contains(param interface{}) sol.BinaryClause {
return col.operator(Contains, param)
}
func (col ColumnElem) ContainedBy(param interface{}) sol.BinaryClause {
return col.operator(ContainedBy, param)
}
func (col ColumnElem) Overlap(param interface{}) sol.BinaryClause {
return col.operator(Overlap, param)
}
func (col ColumnElem) StrictlyLeftOf(param interface{}) sol.BinaryClause {
return col.operator(StrictlyLeftOf, param)
}
func (col ColumnElem) StrictlyRightOf(param interface{}) sol.BinaryClause {
return col.operator(StrictlyRightOf, param)
}
func (col ColumnElem) DoesNotExtendToTheRightOf(param interface{}) sol.BinaryClause {
return col.operator(DoesNotExtendToTheRightOf, param)
}
func (col ColumnElem) DoesNotExtendToTheLeftOf(param interface{}) sol.BinaryClause {
return col.operator(DoesNotExtendToTheLeftOf, param)
}
func (col ColumnElem) IsAdjacentTo(param interface{}) sol.BinaryClause {
return col.operator(IsAdjacentTo, param)
}
func (col ColumnElem) Union(param interface{}) sol.BinaryClause {
return col.operator(Union, param)
}
func (col ColumnElem) Intersection(param interface{}) sol.BinaryClause {
return col.operator(Intersection, param)
}
func (col ColumnElem) Difference(param interface{}) sol.BinaryClause {
return col.operator(Difference, param)
}