forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_joins.go
73 lines (65 loc) · 2.36 KB
/
query_joins.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
package pop
import "fmt"
// Join will append a JOIN clause to the query
func (q *Query) Join(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
fmt.Println("Warning: Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"JOIN", table, on, args})
return q
}
// LeftJoin will append a LEFT JOIN clause to the query
func (q *Query) LeftJoin(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
fmt.Println("Warning: Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"LEFT JOIN", table, on, args})
return q
}
// RightJoin will append a RIGHT JOIN clause to the query
func (q *Query) RightJoin(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
fmt.Println("Warning: Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"RIGHT JOIN", table, on, args})
return q
}
// LeftOuterJoin will append a LEFT OUTER JOIN clause to the query
func (q *Query) LeftOuterJoin(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
fmt.Println("Warning: Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"LEFT OUTER JOIN", table, on, args})
return q
}
// RightOuterJoin will append a RIGHT OUTER JOIN clause to the query
func (q *Query) RightOuterJoin(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
fmt.Println("Warning: Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"RIGHT OUTER JOIN", table, on, args})
return q
}
// LeftInnerJoin will append a LEFT INNER JOIN clause to the query
func (q *Query) LeftInnerJoin(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
fmt.Println("Warning: Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"LEFT INNER JOIN", table, on, args})
return q
}
// RightInnerJoin will append a RIGHT INNER JOIN clause to the query
func (q *Query) RightInnerJoin(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
fmt.Println("Warning: Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"RIGHT INNER JOIN", table, on, args})
return q
}