forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_joins.go
82 lines (73 loc) · 2.67 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
74
75
76
77
78
79
80
81
82
package pop
import (
"github.com/gobuffalo/pop/internal/oncer"
"github.com/gobuffalo/pop/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
}
// LeftInnerJoin will append an INNER JOIN clause to the query
//
// Deprecated: Use InnerJoin instead
func (q *Query) LeftInnerJoin(table string, on string, args ...interface{}) *Query {
oncer.Deprecate(0, "pop.Query#LeftInnerJoin", "Use pop.Query#InnerJoin instead.")
return q.InnerJoin(table, on, args...)
}
// RightInnerJoin will append an INNER JOIN clause to the query
//
// Deprecated: Use InnerJoin instead
func (q *Query) RightInnerJoin(table string, on string, args ...interface{}) *Query {
oncer.Deprecate(0, "pop.Query#RightInnerJoin", "Use pop.Query#InnerJoin instead.")
return q.InnerJoin(table, on, args...)
}
// 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
}