Adds E-R query for bug 1403162

Bug #1403162: "ValueError: Circular reference detected"

Change-Id: Ib21eda7ed52d44bff81c4e1438f7f5628a33d825