Add QRM error if result set is empty when scanning into struct destination.

This commit is contained in:
go-jet 2019-10-10 16:09:44 +02:00
parent 02fafd8a7a
commit 8c9ae77cd8
6 changed files with 61 additions and 22 deletions

View file

@ -50,14 +50,16 @@ func TestScanToInvalidDestination(t *testing.T) {
func TestScanToValidDestination(t *testing.T) {
t.Run("pointer to struct", func(t *testing.T) {
err := query.Query(db, &struct{}{})
dest := []struct{}{}
err := query.Query(db, &dest)
assert.NilError(t, err)
})
t.Run("global query function scan", func(t *testing.T) {
queryStr, args := query.Sql()
err := qrm.Query(nil, db, queryStr, args, &struct{}{})
dest := []struct{}{}
err := qrm.Query(nil, db, queryStr, args, &dest)
assert.NilError(t, err)
})