query.first returns None, instead of raising exception