i'm having an issue with Quick ORM and eager loadi...
# box-products
j
i'm having an issue with Quick ORM and eager loading. I have set up UserProfile and Role and added this to UserProfile:
Copy code
// UserProfile.cfc
function role() {
   return belongsTo( "User" );
}
and I attempt to eager load the role when I query the UserProfile through a User relationship like so:
Copy code
// User.cfc
function profiles() {
   return hasMany("UserProfile").with("role");
}
Then if I try to call profile.getRole() (where profile is a valid profile instance loaded from the user.profiles() call) it returns undefined, and the raw SQL is showing that it passed a null value for RoleId, when I know the database has a valid RoleId. The query to get UserProfiles doesn't seem to include RoleId, which is why I assume it's failing, but why doesn't it?
Hmm... looks like it works if I add the roleId property to the UserProfile entity. Is that right? I thought the point of the belongsTo and other relationship stuff is that you wouldn't need to add the FK columns themselves and Quick would take care of it?
e
I thought the point of the belongsTo and other relationship stuff is that you wouldn’t need to add the FK columns themselves and Quick would take care of it?
That is supposed to be the case. If you can get a reproducable example up as a test case on https://github.com/coldbox-modules/quick I can take a look.
j
if i get a chance i will