不要怂,就是干,撸起袖子干!

Commit c0a86d3b by Bart Nagel

Add test for findAndCountAll with required belongsTo and limit

Test currently fails. See issue #1953.
1 parent 11347233
Showing with 32 additions and 2 deletions
......@@ -141,5 +141,36 @@ describe(Support.getTestDialectTeaser("Include"), function () {
})
it("should return the correct count and rows when using a required belongsTo and a limit", function(done) {
var s = this.sequelize
, Foo = s.define('Foo', {})
, Bar = s.define('Bar', {})
Foo.hasMany(Bar)
Bar.belongsTo(Foo)
s.sync({ force: true }).then(function() {
// Make five instances of Foo
return Foo.bulkCreate([{}, {}, {}, {}, {}])
}).then(function() {
// Make four instances of Bar, related to the last four instances of Foo
return Bar.bulkCreate([{'FooId': 2}, {'FooId': 3}, {'FooId': 4}, {'FooId': 5}])
}).then(function() {
// Query for the first two instances of Foo which have related Bars
return Foo.findAndCountAll({
include: [{ model: Bar, required: true }],
limit: 2
});
}).then(function(result) {
// There should be four total results (Foo instances 2 through 5)
expect(result.count).to.equal(4)
// The first two of those should be returned due to the limit (Foo
// instances 2 and 3)
expect(result.rows.length).to.equal(2)
done()
})
})
})
})
\ No newline at end of file
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!