Fix #1249: support relation by array attributes

Fix #1249: support relation by array attributes
Yes, this version looks safer to me.