fixes error when retrieving a non-existant query

https://www.openproject.org/work_packages/3371.