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

Error normalising data when morphToMany relationship key doesn't exist #119

Closed
DennisOng opened this issue Mar 16, 2018 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@DennisOng
Copy link

DennisOng commented Mar 16, 2018

Stumbled across this today, seems like there's an issue normalising the data when the relationship key is missing, at least for the morphToMany relationship:

export default class Project extends Model {
  static get entity () {
    return 'projects'
  }

  static fields () {
    return {
      id: this.attr(null),
      name: this.attr(''),
      tags: this.morphToMany(Tag, Taggable, 'tag_id', 'taggable_id', 'taggable_type'),
    }
  }
}

Trying to insertOrUpdate with this project object

{
  'id': 1
  'name' 'Hello'
}

(Notice the tag key is missing in the data)

TypeError: related is undefined vuex-orm.esm.js:6894

@kiaking
Copy link
Member

kiaking commented Mar 16, 2018

Thanks for the report! I've reproduced it and made a fix at #120. I'll merge this and release the new version soon!

kiaking added a commit that referenced this issue Mar 16, 2018
#119 Fix where creating morph to many without relation field is failing
@kiaking
Copy link
Member

kiaking commented Mar 16, 2018

This is fixed with Vuex ORM 0.23.1!
https://github.com/vuex-orm/vuex-orm/releases/tag/v0.23.1

Thank you for reporting this issue and I hope the new version will help your development ❤️

@kiaking kiaking closed this as completed Mar 16, 2018
@DennisOng
Copy link
Author

This package is already helping with our development a alot! Thanks for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants