MCPcopy
hub / github.com/go-gorm/gorm / TestJoin

Function TestJoin

clause/joins_test.go:13–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestJoin(t *testing.T) {
14 results := []struct {
15 name string
16 join clause.Join
17 sql string
18 }{
19 {
20 name: "LEFT JOIN",
21 join: clause.Join{
22 Type: clause.LeftJoin,
23 Table: clause.Table{Name: "user"},
24 ON: clause.Where{
25 Exprs: []clause.Expression{clause.Eq{clause.Column{Table: "user_info", Name: "user_id"}, clause.PrimaryColumn}},
26 },
27 },
28 sql: "LEFT JOIN `user` ON `user_info`.`user_id` = `users`.`id`",
29 },
30 {
31 name: "RIGHT JOIN",
32 join: clause.Join{
33 Type: clause.RightJoin,
34 Table: clause.Table{Name: "user"},
35 ON: clause.Where{
36 Exprs: []clause.Expression{clause.Eq{clause.Column{Table: "user_info", Name: "user_id"}, clause.PrimaryColumn}},
37 },
38 },
39 sql: "RIGHT JOIN `user` ON `user_info`.`user_id` = `users`.`id`",
40 },
41 {
42 name: "INNER JOIN",
43 join: clause.Join{
44 Type: clause.InnerJoin,
45 Table: clause.Table{Name: "user"},
46 ON: clause.Where{
47 Exprs: []clause.Expression{clause.Eq{clause.Column{Table: "user_info", Name: "user_id"}, clause.PrimaryColumn}},
48 },
49 },
50 sql: "INNER JOIN `user` ON `user_info`.`user_id` = `users`.`id`",
51 },
52 {
53 name: "CROSS JOIN",
54 join: clause.Join{
55 Type: clause.CrossJoin,
56 Table: clause.Table{Name: "user"},
57 ON: clause.Where{
58 Exprs: []clause.Expression{clause.Eq{clause.Column{Table: "user_info", Name: "user_id"}, clause.PrimaryColumn}},
59 },
60 },
61 sql: "CROSS JOIN `user` ON `user_info`.`user_id` = `users`.`id`",
62 },
63 {
64 name: "USING",
65 join: clause.Join{
66 Type: clause.InnerJoin,
67 Table: clause.Table{Name: "user"},
68 Using: []string{"id"},
69 },
70 sql: "INNER JOIN `user` USING (`id`)",

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.92
BuildMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected