Skip to content

Getter from custom cast is not executed when accessing related models #1849

@vesper8

Description

@vesper8

Environment

No response

Reproduction

related to #1818

Describe the bug

I'm using a custom cast with one of my model fields and that cast provides a getter and a setter.

I just noticed that when I load related models, the getter is not being executed. It is executed fine when I query the model directly but not if I load a parent model.

So here it works well

const requirements = useRepo(Requirement).all()

console.log(requirements); // here the cast is applied and the getter is used

but here it doesn't

const architectureView = useRepo(ArchitectureView) //
  .with('requirements')
  .where('id', this.currentArchitectureView.id)
  .first();

console.log(architectureView.requirements); // here the cast is not applied and the getter is not used

I believe this is a bug right? If it's intended.. is there a way to circumvent that so the getter is always used?

Thanks!

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions