Fixed a bug when fn inside a query on empty relation returned non-empty result