-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mario L Gutierrez
committed
Jul 8, 2015
1 parent
f679e19
commit f4f89d4
Showing
6 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,33 @@ func TestSelectQueryStruct(t *testing.T) { | |
assert.Contains(t, err.Error(), "no rows") | ||
} | ||
|
||
func TestSelectQueryDistinctOn(t *testing.T) { | ||
s := beginTxWithFixtures() | ||
defer s.AutoRollback() | ||
|
||
// Found: | ||
var person Person | ||
err := s. | ||
Select("id", "name", "email"). | ||
DistinctOn("id"). | ||
From("people"). | ||
Where("email = $1", "[email protected]"). | ||
QueryStruct(&person) | ||
assert.NoError(t, err) | ||
assert.True(t, person.ID > 0) | ||
assert.Equal(t, person.Name, "John") | ||
assert.True(t, person.Email.Valid) | ||
assert.Equal(t, person.Email.String, "[email protected]") | ||
|
||
// Not found: | ||
var person2 Person | ||
err = s. | ||
Select("id", "name", "email"). | ||
From("people").Where("email = $1", "[email protected]"). | ||
QueryStruct(&person2) | ||
assert.Contains(t, err.Error(), "no rows") | ||
} | ||
|
||
func TestSelectBySqlQueryStructs(t *testing.T) { | ||
s := beginTxWithFixtures() | ||
defer s.AutoRollback() | ||
|