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

[RFC 403] Identifiers Infra #6247

Merged
merged 6 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,8 @@ 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';
import { IDENTIFIERS } from '@ember-data/canary-features';

const { attr: DSattr, hasMany: DShasMany, belongsTo: DSbelongsTo } = DS;
const { hash } = RSVP;
Expand Down Expand Up @@ -1891,8 +1893,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(...args) {
super(...args);
delete this.__implicitRelationships;
delete this.__relationships;
}
Expand Down Expand Up @@ -1930,7 +1932,16 @@ 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);
if (IDENTIFIERS) {
let identifier = identifierCacheFor(this).getOrCreateRecordIdentifier({
type: modelName,
id,
lid,
});
return new TestRecordData(identifier, storeWrapper);
} else {
return new TestRecordData(modelName, id, lid, storeWrapper);
}
}
return createRecordDataFor.call(this, modelName, id, lid, storeWrapper);
};
Expand Down
1 change: 1 addition & 0 deletions packages/canary-features/addon/default-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export default {
SAMPLE_FEATURE_FLAG: null,
RECORD_DATA_ERRORS: null,
RECORD_DATA_STATE: null,
IDENTIFIERS: null,
};
Loading