Skip to content

Commit

Permalink
implement identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Jul 11, 2019
1 parent 5cf43fd commit 92facfe
Show file tree
Hide file tree
Showing 19 changed files with 792 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import EmberObject from '@ember/object';
import { attr, hasMany, belongsTo } from '@ember-data/model';
import { InvalidError, ServerError } from '@ember-data/adapter/error';
import { JsonApiValidationError } from '@ember-data/store/-private/ts-interfaces/record-data-json-api';
import RecordData, { RecordIdentifier } from '@ember-data/store/-private/ts-interfaces/record-data';
import RecordData from '@ember-data/store/-private/ts-interfaces/record-data';
import { RecordIdentifier } from '@ember-data/store/-private/ts-interfaces/identifier';
import { RECORD_DATA_ERRORS } from '@ember-data/canary-features';

class Person extends Model {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Model from '@ember-data/model';
import testInDebug from 'dummy/tests/helpers/test-in-debug';
import DS from 'ember-data';
import { RecordData, recordDataFor, relationshipsFor, relationshipStateFor } from '@ember-data/store/-private';
import { identifierCacheFor } from '@ember-data/store/-private';

const { attr: DSattr, hasMany: DShasMany, belongsTo: DSbelongsTo } = DS;
const { hash } = RSVP;
Expand Down Expand Up @@ -1891,8 +1892,8 @@ module('integration/relationship/belongs_to Belongs-To Relationships', function(

test("belongsTo relationship doesn't trigger when model data doesn't support implicit relationship", function(assert) {
class TestRecordData extends RecordData {
constructor(modelName, id, clientId, storeWrapper, store) {
super(modelName, id, clientId, storeWrapper, store);
constructor(identifier, storeWrapper) {
super(identifier, storeWrapper);
delete this.__implicitRelationships;
delete this.__relationships;
}
Expand Down Expand Up @@ -1930,7 +1931,12 @@ module('integration/relationship/belongs_to Belongs-To Relationships', function(
const createRecordDataFor = env.store.createRecordDataFor;
env.store.createRecordDataFor = function(modelName, id, lid, storeWrapper) {
if (modelName === 'book1' || modelName === 'section') {
return new TestRecordData(modelName, id, lid, storeWrapper, this);
let identifier = identifierCacheFor(this).getOrCreateRecordIdentifier({
type: modelName,
id,
lid,
});
return new TestRecordData(identifier, storeWrapper);
}
return createRecordDataFor.call(this, modelName, id, lid, storeWrapper);
};
Expand Down
Loading

0 comments on commit 92facfe

Please sign in to comment.