MCPcopy Create free account
hub / github.com/datasweet/datatable / On

Function On

join.go:71–91  ·  view source on GitHub ↗

On creates a "join on" expression ie, as SQL, SELECT * FROM A INNER JOIN B ON B.id = A.user_id Syntax: "[table].[field]", "field"

(fields ...string)

Source from the content-addressed store, hash-verified

69// ie, as SQL, SELECT * FROM A INNER JOIN B ON B.id = A.user_id
70// Syntax: "[table].[field]", "field"
71func On(fields ...string) []JoinOn {
72 var jon []JoinOn
73 for _, f := range fields {
74 matches := rgOn.FindStringSubmatch(f)
75
76 switch len(matches) {
77 case 0:
78 jon = append(jon, JoinOn{Table: "*", Field: f})
79 case 3:
80 t := matches[1]
81 if len(t) == 0 {
82 t = "*"
83 }
84 jon = append(jon, JoinOn{Table: t, Field: matches[2]})
85 default:
86 return nil
87 }
88 }
89
90 return jon
91}
92
93// Using creates a "join using" expression
94// ie, as SQL, SELECT * FROM A INNER JOIN B USING 'field'

Callers 12

TestWhereFunction · 0.92
TestAggregateFunction · 0.92
TestSortFunction · 0.92
TestJoinOnFunction · 0.92
TestInnerJoinFunction · 0.92
TestLeftJoinFunction · 0.92
TestRightJoinFunction · 0.92
TestOuterJoinFunction · 0.92
TestLeftJoinWithExprFunction · 0.92
TestRightJoinWithExprFunction · 0.92
TestJoinWithColumnNameFunction · 0.92

Calls

no outgoing calls

Tested by 12

TestWhereFunction · 0.74
TestAggregateFunction · 0.74
TestSortFunction · 0.74
TestJoinOnFunction · 0.74
TestInnerJoinFunction · 0.74
TestLeftJoinFunction · 0.74
TestRightJoinFunction · 0.74
TestOuterJoinFunction · 0.74
TestLeftJoinWithExprFunction · 0.74
TestRightJoinWithExprFunction · 0.74
TestJoinWithColumnNameFunction · 0.74