Skip to content

Commit 67be3da

Browse files
committed
Fixes #240.
1 parent c6710fb commit 67be3da

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

dist/angular-data.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @author Jason Dobry <jason.dobry@gmail.com>
33
* @file angular-data.js
4-
* @version 1.4.0 - Homepage <http://angular-data.pseudobry.com/>
4+
* @version 1.4.1 - Homepage <http://angular-data.pseudobry.com/>
55
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>
66
* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
77
*
@@ -3542,7 +3542,14 @@ function loadRelations(resourceName, instance, relations, options) {
35423542
if (DSUtils.contains(relations, relationName)) {
35433543
var task;
35443544
var params = {};
3545-
params[def.foreignKey] = instance[definition.idAttribute];
3545+
if (options.allowSimpleWhere) {
3546+
params[def.foreignKey] = instance[definition.idAttribute];
3547+
} else {
3548+
params.where = {};
3549+
params.where[def.foreignKey] = {
3550+
'==': instance[definition.idAttribute]
3551+
};
3552+
}
35463553

35473554
if (def.type === 'hasMany' && params[def.foreignKey]) {
35483555
task = DS.findAll(relationName, params, options);
@@ -4304,6 +4311,7 @@ Defaults.prototype.eagerEject = false;
43044311
Defaults.prototype.notify = true;
43054312
Defaults.prototype.cacheResponse = true;
43064313
Defaults.prototype.upsert = true;
4314+
Defaults.prototype.allowSimpleWhere = true;
43074315
/**
43084316
* @doc property
43094317
* @id DSProvider.properties:defaults.ignoredChanges

dist/angular-data.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datastore/async_methods/loadRelations.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ function loadRelations(resourceName, instance, relations, options) {
101101
if (DSUtils.contains(relations, relationName)) {
102102
var task;
103103
var params = {};
104-
params[def.foreignKey] = instance[definition.idAttribute];
104+
if (options.allowSimpleWhere) {
105+
params[def.foreignKey] = instance[definition.idAttribute];
106+
} else {
107+
params.where = {};
108+
params.where[def.foreignKey] = {
109+
'==': instance[definition.idAttribute]
110+
};
111+
}
105112

106113
if (def.type === 'hasMany' && params[def.foreignKey]) {
107114
task = DS.findAll(relationName, params, options);

src/datastore/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ Defaults.prototype.eagerEject = false;
219219
Defaults.prototype.notify = true;
220220
Defaults.prototype.cacheResponse = true;
221221
Defaults.prototype.upsert = true;
222+
Defaults.prototype.allowSimpleWhere = true;
222223
/**
223224
* @doc property
224225
* @id DSProvider.properties:defaults.ignoredChanges

0 commit comments

Comments
 (0)