CakePHP4 - can not get contain association if limit returned fields

Dear all,

If I limit returned fields like below, I can not get contained associations

$users = $this->Users->find('all', ['fields' => ['id', 'firstname', 'lastname', 'vaccination_id', 'health_id'],
                                        'contain' => ['Vaccinations', 'Healths']
                                        ,'order' => ['firstname' => 'ASC']
                                        ,'conditions' => ['is_active' => true, 'is_deleted' => false
                                            ]
                            ])->all();

If I remove the ‘fields’ option, then Vaccinations and Healths can be retrieve and printed name in view, as below

$users = $this->Users->find('all', [
                                        'contain' => ['Vaccinations', 'Healths']
                                        ,'order' => ['firstname' => 'ASC']
                                        ,'conditions' => ['is_active' => true, 'is_deleted' => false
                                            ,'Users.id' => 154
                                            ]
                            ])->all();

Is this a bug?

No, that’s how it’s supposed to work. Your field list hasn’t included anything from either of your contained tables. See the last two examples of the Passing conditions to contain section of the book for examples of how to do what you want.