Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quick 9.0.2] Calling Relationship Setter on HasManyDeep (HasManyThrough) Throws Exception #255

Open
homestar9 opened this issue Nov 4, 2024 · 0 comments

Comments

@homestar9
Copy link
Contributor

Issue:
Calling relationship setter on a HasManyThrough (HasManyDeep) relationship will throw the exception:
"Method does not exist on QueryBuilder [applySetter]"

How to Replicate:

  1. Define a HasManyThrough relationship:
// Page entity 

// a `Page` has many `Category` through intermediate `PageCategory` entities
function categories() {
      return hasManyThrough( [ "pageCategories", "category" ] );
}

function pageCategories() {
        return hasMany( "PageCategory@cms", "pageId" );
}
  1. Attempt to call the setter in your handler:
prc.page.setCategories( "1,2,3" );

Expected:
I expected the relationship setter to function like the other relationship types and persist the new categories via the PageCategory intermediate entity.

Actual Result:
Throws exception.

Workarounds?
None that I can think of unless you work directly with the intermediate entity relationship, but that creates complexity in your handlers or model, which I believe should be handled by the ORM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant