Skip to content

Commit b760737

Browse files
committed
Fix hasMany.getAccessor().count()
1 parent acf603d commit b760737

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### v2.1.11 - 19 May 2014
2+
- Fix hasMany.getAccessor().count()
3+
4+
### v2.1.10 - 09 May 2014
5+
- Fix sqlite Dialect.clear - resets incremental counters (#497)
6+
17
### v2.1.9 - 06 May 2014
28
- Add basic PostGIS support - (#456, #375)
39
- Allow mapping model properties to differently named columns (#273, #495)

lib/ChainFind.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ function ChainFind(Model, opts) {
7878
return this;
7979
},
8080
count: function (cb) {
81-
opts.driver.count(opts.table, opts.conditions, {}, function (err, data) {
81+
opts.driver.count(opts.table, opts.conditions, {
82+
merge : opts.merge
83+
}, function (err, data) {
8284
if (err || data.length === 0) {
8385
return cb(err);
8486
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"sqlite",
1313
"mongodb"
1414
],
15-
"version" : "2.1.10",
15+
"version" : "2.1.11",
1616
"license" : "MIT",
1717
"homepage" : "http://dresende.github.io/node-orm2",
1818
"repository" : "http://github.com/dresende/node-orm2.git",

test/integration/association-hasmany.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,32 @@ describe("hasMany", function () {
152152
return done();
153153
});
154154
});
155+
156+
it("should allow chaining count()", function (done) {
157+
Person.find({}, function (err, people) {
158+
should.equal(err, null);
159+
160+
people[0].getPets().count(function (err, count) {
161+
should.not.exist(err);
162+
163+
should.strictEqual(count, 2);
164+
165+
people[1].getPets().count(function (err, count) {
166+
should.not.exist(err);
167+
168+
should.strictEqual(count, 1);
169+
170+
people[2].getPets().count(function (err, count) {
171+
should.not.exist(err);
172+
173+
should.strictEqual(count, 0);
174+
175+
return done();
176+
});
177+
});
178+
});
179+
});
180+
});
155181
});
156182

157183
describe("hasAccessor", function () {

test/integration/orm-exports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe("ORM.connect()", function () {
7272
});
7373

7474
it("should allow protocol alias", function (done) {
75-
var db = ORM.connect("pg://unknowndb");
75+
var db = ORM.connect("pg://127.0.0.2");
7676

7777
db.on("connect", function (err) {
7878
should.exist(err);

0 commit comments

Comments
 (0)