FAIMS-349 - fix the query with the deletion of the record