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

strange issue when using difference in 3.0 #148

Open
jamesdixon opened this issue Mar 20, 2017 · 0 comments
Open

strange issue when using difference in 3.0 #148

jamesdixon opened this issue Mar 20, 2017 · 0 comments

Comments

@jamesdixon
Copy link

Hi,
I have a model that has a property which uses the difference macro to, obviously, get the difference between two of the model's properties. Here it is:

import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
import EmberCPM from 'ember-cpm';
const { Macros: { difference } } = EmberCPM;

export default Model.extend({
  business: belongsTo(),
  invoices: hasMany(),

  payments: attr('number'),
  totalBilled: attr('number'),
  unpaid: difference('totalBilled', 'payments')
});

Strangely, I'm getting a NaN for the unpaid property when totalBilled = 15 and payments = 0. Digging into the macro itself, I'm seeing that firstNumber is properly set to 15, but secondNumber is actually the name of the property, payments, rather than 0. Odd, right?

If I downgrade to v2.1.3 of ember-cpm, everything works as expected.

I'm running Ember 2.11.3.

Thanks in advance for any help!

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