Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add assertions #657

Closed
wants to merge 1 commit into from

3 participants

@joliss

I haven't been able to test either of these assertions, but we
encountered both of these issues, and I believe they'd have helped us
track them down much faster.

@joliss joliss Add assertions
I haven't been able to test either of these assertions, but we
encountered both of these issues, and I believe they'd have helped us
track them down much faster.
f47f66e
@darthdeus
Collaborator

Can we merge this?

@igorT
Owner

Yup, this was a supper annoying bug. There are now asserts from b6d4f39

@igorT igorT closed this
@joliss

@igorT You added this one in b6d4f39, correct?

Ember.assert(fmt('Inverse relationship not found or ambiguous: parent %@, child %@, property %@; if ambiguous, add an `inverse` option on the property.', [parentType, childType, belongsToName]), inverseRelationship);

How about this one though, should this still be merged?

// Do not call `materialize` with undefined data.
Ember.assert(fmt('materializeData failed: No data found for clientId "%@"', [clientId]), data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 21, 2013
  1. @joliss

    Add assertions

    joliss authored
    I haven't been able to test either of these assertions, but we
    encountered both of these issues, and I believe they'd have helped us
    track them down much faster.
This page is out of date. Refresh to see the latest.
View
8 packages/ember-data/lib/system/relationships/one_to_many_change.js
@@ -1,4 +1,4 @@
-var get = Ember.get, set = Ember.set;
+var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
var forEach = Ember.EnumerableUtils.forEach;
DS.RelationshipChange = function(options) {
@@ -528,11 +528,13 @@ function inverseBelongsToName(parentType, childType, hasManyName) {
function inverseHasManyName(parentType, childType, belongsToName) {
var options = childType.metaForProperty(belongsToName).options;
- var hasManyName;
+ var hasManyName, inverseRelationship;
if (hasManyName = options.inverse) {
return hasManyName;
}
- return DS._inverseRelationshipFor(parentType, childType).name;
+ inverseRelationship = DS._inverseRelationshipFor(parentType, childType);
+ Ember.assert(fmt('Inverse relationship not found or ambiguous: parent %@, child %@, property %@; if ambiguous, add an `inverse` option on the property.', [parentType, childType, belongsToName]), inverseRelationship);
+ return inverseRelationship.name;
}
View
3  packages/ember-data/lib/system/store.js
@@ -176,6 +176,9 @@ DS.Store = Ember.Object.extend(DS._Mappable, {
adapter = this.adapterForType(record.constructor),
data = cidToData[clientId];
+ // Do not call `materialize` with undefined data.
+ Ember.assert(fmt('materializeData failed: No data found for clientId "%@"', [clientId]), data);
+
cidToData[clientId] = MATERIALIZED;
var prematerialized = this.clientIdToPrematerializedData[clientId];
Something went wrong with that request. Please try again.