Fix random bits that were unfinished.
This commit is contained in:
parent
e4d7f1b8e2
commit
6b966954ee
6 changed files with 13 additions and 4 deletions
1
boil/_fixtures/12.sql
Normal file
1
boil/_fixtures/12.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
SELECT "cats".* FROM "cats" INNER JOIN dogs d on d.cat_id = cats.id;
|
1
boil/_fixtures/13.sql
Normal file
1
boil/_fixtures/13.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
SELECT "c".* FROM cats c INNER JOIN dogs d on d.cat_id = cats.id;
|
1
boil/_fixtures/14.sql
Normal file
1
boil/_fixtures/14.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
SELECT "c".* FROM cats as c INNER JOIN dogs d on d.cat_id = cats.id;
|
1
boil/_fixtures/15.sql
Normal file
1
boil/_fixtures/15.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
SELECT "c".*, "d".* FROM cats as c, dogs as d INNER JOIN dogs d on d.cat_id = cats.id;
|
|
@ -260,22 +260,23 @@ func writeModifiers(q *Query, buf *bytes.Buffer, args *[]interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeStars(q *Query) []string {
|
func writeStars(q *Query) []string {
|
||||||
cols := make([]string, 0, len(q.from))
|
cols := make([]string, len(q.from))
|
||||||
for _, f := range q.from {
|
for i, f := range q.from {
|
||||||
toks := strings.Split(f, " ")
|
toks := strings.Split(f, " ")
|
||||||
if len(toks) == 1 {
|
if len(toks) == 1 {
|
||||||
cols = append(cols, fmt.Sprintf(`%s.*`, strmangle.IdentQuote(toks[0])))
|
cols[i] = fmt.Sprintf(`%s.*`, strmangle.IdentQuote(toks[0]))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
alias, name, ok := parseFromClause(toks)
|
alias, name, ok := parseFromClause(toks)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(alias) != 0 {
|
if len(alias) != 0 {
|
||||||
name = alias
|
name = alias
|
||||||
}
|
}
|
||||||
cols = append(cols, fmt.Sprintf(`%s.*`, strmangle.IdentQuote(name)))
|
cols[i] = fmt.Sprintf(`%s.*`, strmangle.IdentQuote(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
return cols
|
return cols
|
||||||
|
|
|
@ -89,6 +89,10 @@ func TestBuildQuery(t *testing.T) {
|
||||||
},
|
},
|
||||||
limit: 5,
|
limit: 5,
|
||||||
}, []interface{}{2, 3, 1, 4, 5, 6, 7, 8, 9, 10}},
|
}, []interface{}{2, 3, 1, 4, 5, 6, 7, 8, 9, 10}},
|
||||||
|
{&Query{from: []string{"cats"}, joins: []join{{JoinInner, "dogs d on d.cat_id = cats.id", nil}}}, nil},
|
||||||
|
{&Query{from: []string{"cats c"}, joins: []join{{JoinInner, "dogs d on d.cat_id = cats.id", nil}}}, nil},
|
||||||
|
{&Query{from: []string{"cats as c"}, joins: []join{{JoinInner, "dogs d on d.cat_id = cats.id", nil}}}, nil},
|
||||||
|
{&Query{from: []string{"cats as c", "dogs as d"}, joins: []join{{JoinInner, "dogs d on d.cat_id = cats.id", nil}}}, nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
|
Loading…
Reference in a new issue