public function findAccountManagers(Query $query, array $options)
{
return $query->innerJoinWith('UserTypes', function ($q) {
return $q->where([
'UserTypes.name' => 'Account Manager'
]);
})
}
This works fine when adding Jobs, etc. Only users with that UserType are presented in the drop down. However when using a Paginator for the jobs index page, I get a generic “Database Error”:
“Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘UserTypes.name’ in ‘on clause’”
The code for paginating is from cake bake:
public function index()
{
$this->paginate = [
'contain' => ['AccountManagers']
];
$jobs = $this->paginate($this->Jobs);
$this->set(compact('jobs'));
$this->set('_serialize', ['jobs']);
}
Not sure where I’m going wrong since the relationship seems to be set up correctly. but I’m not sure why the join with the UserTypes table is failing here.
Not sure how. The error seems to be triggered on the $this->paginate() function call, so the error is being thrown before the application reaches the debug() call.
After speaking to several people in the Slack chat, the prevailing consensus was this was actually a bug, and I have reported it to the devs: https://github.com/cakephp/cakephp/issues/8892