Skip to content

Commit f698dbc

Browse files
committed
omit should return instances populated ids and foreign keys
1 parent 79e7022 commit f698dbc

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

lib/ChainFind.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function ChainFind(Model, opts) {
4545
} else {
4646
omit = Array.prototype.slice.apply(arguments);
4747
}
48-
this.only(_.difference(Object.keys(Model.properties), omit));
48+
this.only(_.difference(Object.keys(Model.allProperties), omit));
4949
return this;
5050
},
5151
limit: function (limit) {

test/integration/model-find-chain.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,26 @@ describe("Model.find() chaining", function() {
1616
age : Number
1717
});
1818
Person.hasMany("parents");
19+
Person.hasOne("friend");
1920

2021
ORM.singleton.clear(); // clear cache
2122

2223
return helper.dropSync(Person, function () {
2324
Person.create([{
24-
name : "John",
25-
surname : "Doe",
26-
age : 18
25+
name : "John",
26+
surname : "Doe",
27+
age : 18,
28+
friend_id : 1
2729
}, {
28-
name : "Jane",
29-
surname : "Doe",
30-
age : 20
30+
name : "Jane",
31+
surname : "Doe",
32+
age : 20,
33+
friend_id : 1
3134
}, {
32-
name : "Jane",
33-
surname : "Dean",
34-
age : 18
35+
name : "Jane",
36+
surname : "Dean",
37+
age : 18,
38+
friend_id : 1
3539
}], done);
3640
});
3741
};
@@ -215,6 +219,8 @@ describe("Model.find() chaining", function() {
215219
Person.find().omit("age", "surname").order("-age").run(function (err, instances) {
216220
should.equal(err, null);
217221
instances.should.have.property("length", 3);
222+
should.exist(instances[0].id);
223+
should.exist(instances[0].friend_id);
218224
instances[0].should.have.property("age", null);
219225
instances[0].should.have.property("surname", null);
220226
instances[0].should.have.property("name", "Jane");

0 commit comments

Comments
 (0)