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

without calling hasMany('foo').remoteType() the remote type may change in 2.14+ #5348

Closed
luxzeitlos opened this issue Feb 1, 2018 · 1 comment

Comments

@luxzeitlos
Copy link
Contributor

Assuming we have the following models:

Bar:

export default DS.Model.extend({
  foo: DS.belongsTo('foo'),
});

Foo:

export default DS.Model.extend({
  bars: DS.hasMany('bar'),
});

Now assume the following code:

store.push({
  data: {
    id: '1',
    type: 'foo',
    relationships: {
      bars: {
        links: {
          related: '/api/foo/1/relationships/bars/data/'
        }
      }
    }
  }
});

const foo = store.peekRecord('foo', '1');

// In 2.14+ if this line is is active the `remoteType` will be fixed and so be `link`. However if its not active the following call to `store.push` will change the `remoteType` to `ids`. This will also cause the behaviour of `reload()` to change. In 2.13 the remoteType will never be `ids`.
// console.log(foo.hasMany('bars').remoteType());

store.push({
  data: {
    id: '1',
    type: 'bar',
    relationships: {
      foo: {
        data: {
          id: '1',
          type: 'foo',
        }
      }
    }
  }
});

// in 2.13 this will always return `link`. However in 2.14+ this will return `ids` when remoteType() has not been called before the second store.push, otherwise it will be link.
console.log(foo.hasMany('bars').remoteType());
@runspired
Copy link
Contributor

This should have been resolved with #5410, please reopen if it was not.

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

2 participants