fix a bug with prepared select statements that return no results

With test