diff --git a/packages/ember-data/lib/system/relationships/belongs-to.js b/packages/ember-data/lib/system/relationships/belongs-to.js index 6b2ee6df650..d052b4ee14b 100644 --- a/packages/ember-data/lib/system/relationships/belongs-to.js +++ b/packages/ember-data/lib/system/relationships/belongs-to.js @@ -91,18 +91,12 @@ function belongsTo(modelName, options) { opts = opts || {}; - var shouldWarnAsync = false; - if (typeof opts.async === 'undefined') { - shouldWarnAsync = true; - } - var meta = { type: userEnteredModelName, isRelationship: true, options: opts, kind: 'belongsTo', - key: null, - shouldWarnAsync: shouldWarnAsync + key: null }; return Ember.computed({ @@ -110,11 +104,6 @@ function belongsTo(modelName, options) { Ember.warn('You provided a serialize option on the "' + key + '" property in the "' + this._internalModel.modelName + '" class, this belongs in the serializer. See DS.Serializer and it\'s implementations http://emberjs.com/api/data/classes/DS.Serializer.html', !opts.hasOwnProperty('serialize')); Ember.warn('You provided an embedded option on the "' + key + '" property in the "' + this._internalModel.modelName + '" class, this belongs in the serializer. See DS.EmbeddedRecordsMixin http://emberjs.com/api/data/classes/DS.EmbeddedRecordsMixin.html', !opts.hasOwnProperty('embedded')); - if (meta.shouldWarnAsync) { - Ember.deprecate(`In Ember Data 2.0, relationships will be asynchronous by default. You must set \`${key}: DS.belongsTo('${modelName}', { async: false })\` if you wish for a relationship remain synchronous.`); - meta.shouldWarnAsycn = false; - } - return this._internalModel._relationships.get(key).getRecord(); }, set: function(key, value) { diff --git a/packages/ember-data/lib/system/relationships/has-many.js b/packages/ember-data/lib/system/relationships/has-many.js index 6acd4e96519..33b50315649 100644 --- a/packages/ember-data/lib/system/relationships/has-many.js +++ b/packages/ember-data/lib/system/relationships/has-many.js @@ -121,11 +121,6 @@ function hasMany(type, options) { options = options || {}; - var shouldWarnAsync = false; - if (typeof options.async === 'undefined') { - shouldWarnAsync = true; - } - if (typeof type === 'string') { type = normalizeModelName(type); } @@ -139,16 +134,11 @@ function hasMany(type, options) { isRelationship: true, options: options, kind: 'hasMany', - key: null, - shouldWarnAsync: shouldWarnAsync + key: null }; return Ember.computed({ get: function(key) { - if (meta.shouldWarnAsync) { - Ember.deprecate(`In Ember Data 2.0, relationships will be asynchronous by default. You must set \`${key}: DS.hasMany('${type}', { async: false })\` if you wish for a relationship remain synchronous.`); - meta.shouldWarnAsync = false; - } var relationship = this._internalModel._relationships.get(key); return relationship.getRecords(); }, diff --git a/packages/ember-data/lib/system/relationships/state/relationship.js b/packages/ember-data/lib/system/relationships/state/relationship.js index 3a8ccb94feb..cf78b1d2df4 100644 --- a/packages/ember-data/lib/system/relationships/state/relationship.js +++ b/packages/ember-data/lib/system/relationships/state/relationship.js @@ -1,13 +1,14 @@ import OrderedSet from "ember-data/system/ordered-set"; export default function Relationship(store, record, inverseKey, relationshipMeta) { + var async = relationshipMeta.options.async; this.members = new OrderedSet(); this.canonicalMembers = new OrderedSet(); this.store = store; this.key = relationshipMeta.key; this.inverseKey = inverseKey; this.record = record; - this.isAsync = relationshipMeta.options.async; + this.isAsync = typeof async === 'undefined' ? true : async; this.relationshipMeta = relationshipMeta; //This probably breaks for polymorphic relationship in complex scenarios, due to //multiple possible modelNames diff --git a/packages/ember-data/tests/integration/filter-test.js b/packages/ember-data/tests/integration/filter-test.js index acb2fd8243f..eb377062a4f 100644 --- a/packages/ember-data/tests/integration/filter-test.js +++ b/packages/ember-data/tests/integration/filter-test.js @@ -43,7 +43,7 @@ module("integration/filter - DS.Model updating", { name: 'Scumbag Bryn' } }]; - Person = DS.Model.extend({ name: DS.attr('string'), bestFriend: DS.belongsTo('person', { inverse: null }) }); + Person = DS.Model.extend({ name: DS.attr('string'), bestFriend: DS.belongsTo('person', { inverse: null, async: false }) }); env = setupStore({ person: Person }); store = env.store; diff --git a/packages/ember-data/tests/unit/model/relationships/belongs-to-test.js b/packages/ember-data/tests/unit/model/relationships/belongs-to-test.js index e681e9063b0..f01b3158fec 100644 --- a/packages/ember-data/tests/unit/model/relationships/belongs-to-test.js +++ b/packages/ember-data/tests/unit/model/relationships/belongs-to-test.js @@ -312,13 +312,7 @@ test("belongsTo gives a warning when provided with an embedded option", function }, /You provided an embedded option on the "hobby" property in the "person" class, this belongs in the serializer. See DS.EmbeddedRecordsMixin/); }); -module("unit/model/relationships - DS.belongsTo async by default deprecations", { - setup: function() { - setupStore(); - } -}); - -test("setting DS.belongsTo without async false triggers deprecation", function() { +test("DS.belongsTo should be async by default", function() { var Tag = DS.Model.extend({ name: DS.attr('string'), people: DS.hasMany('person', { async: false }) @@ -332,12 +326,10 @@ test("setting DS.belongsTo without async false triggers deprecation", function() var env = setupStore({ tag: Tag, person: Person }); var store = env.store; - expectDeprecation( - function() { - run(function() { - store.createRecord('person').get('tag'); - }); - }, - /In Ember Data 2.0, relationships will be asynchronous by default. You must set `tag: DS.belongsTo\('tag', { async: false }\)`/ - ); + + run(function() { + var person = store.createRecord('person'); + + ok(person.get('tag') instanceof DS.PromiseObject, 'tag should be an async relationship'); + }); }); diff --git a/packages/ember-data/tests/unit/model/relationships/has-many-test.js b/packages/ember-data/tests/unit/model/relationships/has-many-test.js index ae21ccd68f0..b33f4da0648 100644 --- a/packages/ember-data/tests/unit/model/relationships/has-many-test.js +++ b/packages/ember-data/tests/unit/model/relationships/has-many-test.js @@ -468,13 +468,7 @@ test("it is possible to add an item to a relationship, remove it, then add it ag equal(tags.objectAt(2), tag3); }); -module("unit/model/relationships - DS.hasMany async by default deprecations", { - setup: function() { - env = setupStore(); - } -}); - -test("setting DS.hasMany without async false triggers deprecation", function() { +test("DS.hasMany is async by default", function() { var Tag = DS.Model.extend({ name: DS.attr('string'), people: DS.hasMany('person') @@ -488,12 +482,8 @@ test("setting DS.hasMany without async false triggers deprecation", function() { var env = setupStore({ tag: Tag, person: Person }); var store = env.store; - expectDeprecation( - function() { - run(function() { - store.createRecord('tag').get('people'); - }); - }, - /In Ember Data 2.0, relationships will be asynchronous by default. You must set `people: DS.hasMany\('person', { async: false }\)/ - ); + run(function() { + var tag = store.createRecord('tag'); + ok(tag.get('people') instanceof DS.PromiseArray, 'people should be an async relationship'); + }); });