database: queries throw runtime exception with query when invalid