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

Initialize empty toOne relationships actually empty #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aars
Copy link
Collaborator

@aars aars commented Mar 7, 2017

ObjectProxys for toOne relationships were initialised with a fresh Ember.Object.create() as their content. Because of this, you can not do this:

if (resource.get('some-to-one-relationship')) { ... } or {{#if resource.some-to-one-relationship}} ... {{/if}}

resource.get('some-to-one-relationship.content') would not work either. You'd have to go look for attributes:resource.get('some-to-one-relationship.id').
But that doesn't work either, since there isn't really an attribute that should always be set... Maybe type, but that's just a hack.

By initialising with something falsy like null, we're all good.

@pixelhandler
Copy link
Owner

@andrewmp1 what do you think about initializing with null ?

@aars
Copy link
Collaborator Author

aars commented Mar 20, 2017

This issue can also be resolved in the toOne-promise-aware PR (and/or the upcoming change on that one, using the proxy).

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.

2 participants