PhilWaldmann / openrecord

Make ORMs great again!
https://openrecord.js.org
MIT License
486 stars 38 forks source link

deeply nested relations do not inherit context #51

Closed SampsonCrowley closed 7 years ago

SampsonCrowley commented 7 years ago

functions from an inherited Model don't have context

return Model
.join({athlete: 'user'})
.get(invId)
.exec()
.then((result) => {
  account = result;
  console.log(account.context); //HAS CONTEXT
  console.log(account.athlete.context); //HAS CONTEXT
  console.log(account.athlete.user.context); //DOES NOT HAVE CONTEXT
  return user = account.athlete.user;
})
SampsonCrowley commented 7 years ago

I fixed the original issue, just to run into the same problem with "new" records. My latest pull request will fix both issues

SampsonCrowley commented 7 years ago

I have discovered that deeply nested new records are not saving unless I explicitly save its parent. (not related to my pull request)