fix IdentityMap not storing relation keys properly

also reported in Issue #2877