Navigation Menu

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

Give Model a static toString method #5117

Merged
merged 2 commits into from Apr 22, 2018

Conversation

DingoEatingFuzz
Copy link
Contributor

This changes the dreaded (unknown mixin) to something like model:person.

This will make things like this error much more useful:

Error: Assertion Failed: You defined the 'run' relationship on (unknown mixin), but multiple possible inverse relationships of type (unknown mixin) were found on (unknown mixin). Look at http://emberjs.com/guides/models/defining-models/#toc_explicit-inverses for how to explicitly specify inverses

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me!

@rwjblue
Copy link
Member

rwjblue commented Aug 14, 2017

If you rebase (to get 49a66fe) this should pass in CI...

@rwjblue
Copy link
Member

rwjblue commented Aug 14, 2017

@runspired - Wanted to get your thoughts here too...

@runspired
Copy link
Contributor

I thought Stef had recently fixed this, hrm

@stefanpenner
Copy link
Member

This is fixed, if you load models via the container and a modern resolver. The above should only benefit tests. And if so, should likely be a test specific reopen.

@DingoEatingFuzz
Copy link
Contributor Author

@stefanpenner, can you elaborate?

This code:

  model() {
    return RSVP.hash({
      nodes: this.get('store').findAll('node'),
      agents: this.get('store').findAll('agent'),
    }).then(({ nodes }) => {
      console.log(nodes.get('firstObject').toString());
      console.log(nodes.get('firstObject').constructor.toString());
    });
  },

Yields this output:

<nomad-ui@model:node::ember844:69b5c85f-5356-4365-b75a-e37ca76adfc3>
(subclass of DS.Model)

With these dependencies:

DEBUG: Ember           : 2.14.1
DEBUG: Ember Data      : 2.14.4

Was this fixed after 2.14.4, or is there another explanation?

@stefanpenner
Copy link
Member

<nomad-ui@model:node::ember844:69b5c85f-5356-4365-b75a-e37ca76adfc3>
(subclass of DS.Model)

ah..

@stefanpenner
Copy link
Member

This seems reasonable, unless we want to remove modelName from classes, as that attribute does pollute the class...

I'll have to think about this some more.

@rwjblue
Copy link
Member

rwjblue commented Aug 15, 2017

IMHO, deprecating modelName is a separate concern, we should just make sure that we don't box ourselves in a corner with it. IMHO, the same thing could be solved without modelName via _debugContainerKey (for example)...

@stefanpenner
Copy link
Member

stefanpenner commented Aug 15, 2017

IMHO, the same thing could be solved without modelName via _debugContainerKey (for example)...

On the class, I don't believe we put _debugContainerKey on the class?

Copy link
Member

@stefanpenner stefanpenner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would like to move away from modelName on class's. This would be at odds with that goal. I'm not sure how to proceed.

@runspired
Copy link
Contributor

I don't believe it is possible for us to move off of modelName being on DS.Model without moving to ES Classes. Moving to ES Classes is on the roadmap anyway, and would mean that the class name would be available (and the default) for this situation. Due to this, I personally do not see any issue with moving this PR forward with the use of modelName.

@rwjblue @stefanpenner what do you think?

@rwjblue
Copy link
Member

rwjblue commented Apr 21, 2018

Moving away from modelName just means we need some other mechanism for the same rough thing, whenever we add that we can easily update this toString implementation...

DingoEatingFuzz and others added 2 commits April 21, 2018 21:38
This changes the dreaded (unknown mixin) to something like
model:person.
@runspired runspired merged commit 87be9b7 into emberjs:master Apr 22, 2018
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

Successfully merging this pull request may close these issues.

None yet

4 participants