-
-
Notifications
You must be signed in to change notification settings - Fork 243
/
query_joins.go
65 lines (58 loc) · 2.02 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
package pop
import (
"github.com/gobuffalo/pop/v6/logging"
)
// Join will append a JOIN clause to the query
func (q *Query) Join(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
log(logging.Warn, "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 != "" {
log(logging.Warn, "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 != "" {
log(logging.Warn, "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 != "" {
log(logging.Warn, "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 != "" {
log(logging.Warn, "Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"RIGHT OUTER JOIN", table, on, args})
return q
}
// InnerJoin will append an INNER JOIN clause to the query
func (q *Query) InnerJoin(table string, on string, args ...interface{}) *Query {
if q.RawSQL.Fragment != "" {
log(logging.Warn, "Query is setup to use raw SQL")
return q
}
q.joinClauses = append(q.joinClauses, joinClause{"INNER JOIN", table, on, args})
return q
}