good morning!!!!

Skip to content
Snippets Groups Projects
Commit 15ddc45d authored by José Carlos Nieto's avatar José Carlos Nieto
Browse files

Adding test for CROSS JOIN.

parent 74e1e8cc
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,8 @@ const (
{{ else if .Using }}
{{.Type}} JOIN {{.Table}}
{{.Using}}
{{ else if .Type | eq "CROSS" }}
{{.Type}} JOIN {{.Table}}
{{else}}
NATURAL {{.Type}} JOIN {{.Table}}
{{end}}
......
......@@ -54,8 +54,12 @@ func (j *Joins) Compile(layout *Template) (compiled string) {
}
// JoinConditions creates a Joins object.
func JoinConditions(joins ...Fragment) *Joins {
return &Joins{Conditions: joins}
func JoinConditions(joins ...*Join) *Joins {
fragments := make([]Fragment, len(joins))
for i := range fragments {
fragments[i] = joins[i]
}
return &Joins{Conditions: fragments}
}
// Join represents a generic JOIN statement.
......
......@@ -153,6 +153,22 @@ func TestNaturalInnerJoinOn(t *testing.T) {
}
}
func TestCrossJoin(t *testing.T) {
var s, e string
join := JoinConditions(&Join{
Type: "CROSS",
Table: TableWithName("countries"),
})
s = trim(join.Compile(defaultTemplate))
e = `CROSS JOIN "countries"`
if s != e {
t.Fatalf("Got: %s, Expecting: %s", s, e)
}
}
func TestMultipleJoins(t *testing.T) {
var s, e string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment