Fixes an issue with erroneous erasing of polymorphic relations.