Deal with null returns with query

@jsteiner @gabebw
someone really cool wrote this i bet