Adding a limit() to an eager-load constraint limits all entities, not just the constraint

Description

We want to load a user record and eager-load no more than one background check record per user, as such:

But instead of every user getting no more than one background check, the first user gets a background check loaded and every subsequent user returns null for getBackgroundChecks().

Environment

None

Activity

Show:
Eric Peterson
January 3, 2020, 4:01 AM

That is expected. I’m assuming this is a has many relationship. That means that the query looks like so:

What you want is a separate relationship like firstBackgroundCheck or latestBackgroundCheck that is a hasOne relationship.

Known Error

Assignee

Eric Peterson

Reporter

Samuel W. Knowlton

Labels

None

Priority

Major