ziutek/mymysql — Issue #13: 'select sum(...)' results in 'no rows in result set'
Author: aimxhaisse
Created: 2012-03-03 15:53:39+00:00
State: open

Hi,

I'm not sure if I'm missing something important, but it seems that there's no way to perform "SELECT SUM(...)" queries without triggering an error. I'm using the godrv interface, and I haven't tested this behavior with other interfaces. Here is a test that fails (added at the end of driver_test.go):

var num int

// Ok
row := db.QueryRow("select 41 as test")
err = row.Scan(&num)
checkErr(t, err)

// Fails
row = db.QueryRow("select sum(41) as test")
err = row.Scan(&num)
checkErr(t, err)

Both queries return the same result using a MySQL client, the first test passes, but the second fails with the following error:

sql: no rows in result set