Skip to content

Commit a5655e6

Browse files
committed
add outer join
1 parent 54f0c9f commit a5655e6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

orm/query_join.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ import (
44
"strings"
55
)
66

7+
type JoinType string
8+
9+
const (
10+
JoinTypeInner JoinType = "inner join"
11+
JoinTypeLeft JoinType = "left join"
12+
JoinTypeRight JoinType = "right join"
13+
JoinTypeOuter JoinType = "outer join"
14+
)
15+
716
func (m Query[T]) Join(table Table, where func(join Query[T]) Query[T], alias ...string) Query[T] {
817
return m.join(JoinTypeInner, table, where, alias...)
918
}
@@ -13,6 +22,9 @@ func (m Query[T]) LeftJoin(table Table, where func(join Query[T]) Query[T], alia
1322
func (m Query[T]) RightJoin(table Table, where func(join Query[T]) Query[T], alias ...string) Query[T] {
1423
return m.join(JoinTypeRight, table, where, alias...)
1524
}
25+
func (m Query[T]) OuterJoin(table Table, where func(join Query[T]) Query[T], alias ...string) Query[T] {
26+
return m.join(JoinTypeOuter, table, where, alias...)
27+
}
1628

1729
func (m Query[T]) join(joinType JoinType, table Table, wheref func(Query[T]) Query[T], alias ...string) Query[T] {
1830
newTable, err := m.parseTable(table)

orm/query_table.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ import (
55
"strings"
66
)
77

8-
type JoinType string
9-
10-
const (
11-
JoinTypeInner JoinType = "join"
12-
JoinTypeLeft JoinType = "left join"
13-
JoinTypeRight JoinType = "right join"
14-
)
15-
168
type queryTable struct {
179
table Table
1810
tableStruct reflect.Value

0 commit comments

Comments
 (0)