CRM-13059 fix relationship killing query