QRM returns sql.ErrNoRows when scanning into struct destination and query result set is empty.

This commit is contained in:
go-jet 2019-10-12 18:45:09 +02:00
parent 3544977d7f
commit f9efee77ff
7 changed files with 103 additions and 90 deletions

View file

@ -1,7 +1,6 @@
package postgres
import (
"database/sql"
"fmt"
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/postgres"
@ -1798,13 +1797,3 @@ func TestJoinViewWithTable(t *testing.T) {
assert.Equal(t, len(dest[0].Rentals), 32)
assert.Equal(t, len(dest[1].Rentals), 27)
}
func TestErrNoRows(t *testing.T) {
query := SELECT(Customer.AllColumns).FROM(Customer).WHERE(Customer.CustomerID.EQ(Int(-1)))
customer := model.Customer{}
err := query.Query(db, &customer)
assert.Error(t, err, sql.ErrNoRows.Error())
}