Skip to content

Commit

Permalink
Add a query expansion test
Browse files Browse the repository at this point in the history
  • Loading branch information
xiam committed Feb 15, 2017
1 parent 71e161d commit 337a38c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/sqlbuilder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func TestSelect(t *testing.T) {
b.Select().Distinct(db.Raw(`ON("col1") AS col1`)).Columns("col2", "col3").Distinct("col4", "col5").From("artist").String(),
)

assert.Equal(
`SELECT DISTINCT ON(SELECT foo FROM bar) col1, "col2", "col3", "col4", "col5" FROM "artist"`,
b.Select().Distinct(db.Raw(`ON(?) col1`, db.Raw(`SELECT foo FROM bar`))).Columns("col2", "col3").Distinct("col4", "col5").From("artist").String(),
)

{
rawCase := db.Raw("CASE WHEN id IN ? THEN 0 ELSE 1 END", []int{1000, 2000})
sel := b.SelectFrom("artist").OrderBy(rawCase)
Expand Down

0 comments on commit 337a38c

Please sign in to comment.