Skip to content

strange issue when using difference in 3.0 #148

Description

@jamesdixon

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions