Attachment fixes

ifnull(file_name, '')!='' and ifnull(content_hash, '')=''