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

add support for ember-data-model-fragments #28

Merged
merged 3 commits into from
Apr 24, 2019
Merged

add support for ember-data-model-fragments #28

merged 3 commits into from
Apr 24, 2019

Conversation

jakesjews
Copy link
Contributor

@jakesjews jakesjews commented Mar 26, 2019

Fix copying model fragments. Resolves #23

@@ -154,14 +154,14 @@ export default Mixin.create({
) {
let value = this.get(name);

if (Copyable && Copyable.detect(value)) {
if ((Copyable && Copyable.detect(value)) || (value && value._isFragment)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Are all model fragments copyable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are. For some reason Copyable.detect didn't seem to work.

// "value" is an Ember.Object using the ember-copy addon
// (ie. old deprecated Ember.Copyable API - if you use
// the "Ember Data Model Fragments" addon and "value" is a fragment or
// if use your own serializer where you deserialize a value to an
// Ember.Object using this Ember.Copyable API)
value = value.copy(deep);
} else {
} else if (value) {
Copy link
Owner

Choose a reason for hiding this comment

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

What is the reason for this change? Previously all values should be run through their transforms even if falsy. For example, you can have a vale of NaN that can have a custom transform to be Not a Number or 0, etc...

Copy link
Contributor Author

@jakesjews jakesjews Apr 4, 2019

Choose a reason for hiding this comment

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

It's to prevent serializing a null fragment value since that throws an exception. I can change the check to make sure its not a fragment to prevent reaching this branch in that case.

Copy link
Owner

Choose a reason for hiding this comment

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

I can change the check to make sure its not a fragment to prevent reaching this branch in that case.

Yeah, I would rather the check be explicit.

@jakesjews
Copy link
Contributor Author

Looks like the CI failure is from a new ember-data. I'm not quite sure if its from my changes

@offirgolan
Copy link
Owner

All good, Just beta and canary are failing. Changes look good. Thanks for taking this up @jakesjews!

@offirgolan offirgolan merged commit ed0f4ac into offirgolan:master Apr 24, 2019
@offirgolan
Copy link
Owner

Released with v1.1.0.

@jakesjews
Copy link
Contributor Author

thanks!

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.

Model with fragment error
2 participants