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

mask attribute ignored on related models #365

Open
jacek-dargiel opened this issue Jan 8, 2016 · 2 comments
Open

mask attribute ignored on related models #365

jacek-dargiel opened this issue Jan 8, 2016 · 2 comments
Labels

Comments

@jacek-dargiel
Copy link

If a resource has a defined relation with another resource, then setting a mask attribute doesn't work. For example:

 angular.module('mapping')
  .factory('UserResource', function (restmod) {
    return restmod.model('/api/users').mix({
      'Profile':{
        belongsTo: 'ProfileResource',
        mask: 'CU'
      },
      'Posts':{
        belongsToMany: 'PostResource',
        mask: 'CU'
      }
    });
  })
  .factory('ProfileResource', function (restmod) {
    return restmod.model('/api/profile');
  })
  .factory('PostResource', function (restmod) {
    return restmod.model('/api/users');
  });

Using the above code, if you get a user using var user = UserResource.$find(1), and then save it using user.$save(), the actual request has profile_id, and post_ids attributes sent, ignoring the U flags.

@jpulec
Copy link
Contributor

jpulec commented Apr 19, 2016

I ran into this same problem. Turns out, 764b562 broke this functionality because the relation attribute mapping will now happen after your mask mapping. Since the relationship mapping explicitly sets the mask on your relation, it overwrites your mask. For now version 1.9 still functions correctly with the old behavior

@jpulec jpulec added the bug label Sep 26, 2016
@jpulec jpulec self-assigned this Sep 26, 2016
@utf4
Copy link

utf4 commented Nov 3, 2016

You can separate it out in 2 mixins one with the masks and other with the relations as a work around?

@jpulec jpulec removed their assignment Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants