10000 check that inverseDef exists before attempting to setup Inverse for belongsTo by pik · Pull Request #382 · js-data/js-data · GitHub
[go: up one dir, main page]

Skip to content

check that inverseDef exists before attempting to setup Inverse for belongsTo #382

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

Merged
merged 3 commits into from
Aug 3, 2016
Merged
Changes from 1 commit
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
Next Next commit
belongsTo errors without inverse relation
  • Loading branch information
pik committed Aug 2, 2016
commit aaf9f2ca99495e5b419684e9c046ec3446a58fd0
19 changes: 19 additions & 0 deletions test/unit/decorators/belongsTo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ describe('JSData.belongsTo', function () {
assert.strictEqual(bar2.foo, foo)
assert.strictEqual(bar3.foo, foo)
})

it ('should not create an inverseLink if no inverseRelationship is defined', function() {
const store = new JSData.DataStore()
store.defineMapper('foo', {
})
store.defineMapper('bar', {
relations: {
belongsTo: {
foo: {
localField: '_foo',
foreignKey: 'foo_id'
}
}
}
})
const foo = store.add('foo', { id: 1 })
const bar = store.add('bar', { id: 1, foo_id: 1 })
})

it('should add property accessors to prototype of target and allow relation re-assignment using customizations', function () {
const store = new JSData.DataStore()
store.defineMapper('foo', {
Expand Down
0