fix for Collection#group

This commit is contained in:
Mike Dirolf 2009-08-19 15:18:42 -04:00
parent bb13fbe687
commit c49c208bff
2 changed files with 9 additions and 2 deletions

View File

@ -317,8 +317,9 @@ function () {
var obj = c.next(); var obj = c.next();
var key = {}; var key = {};
for (var i in keys) { for (var i = 0; i < keys.length; i++) {
key[keys[i]] = obj[keys[i]]; var k = keys[i];
key[k] = obj[k];
} }
var aggObj = map.get(key); var aggObj = map.get(key);

View File

@ -607,6 +607,12 @@ class DBAPITest < Test::Unit::TestCase
assert_equal 3, test.group([], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }")[0]["count"] assert_equal 3, test.group([], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }")[0]["count"]
assert_equal 1, test.group([], {"a" => {"$gt" => 1}}, {"count" => 0}, "function (obj, prev) { prev.count++; }")[0]["count"] assert_equal 1, test.group([], {"a" => {"$gt" => 1}}, {"count" => 0}, "function (obj, prev) { prev.count++; }")[0]["count"]
test.insert("a" => 2, "b" => 3)
expected = [{"a" => 2, "count" => 2},
{"a" => nil, "count" => 1},
{"a" => 1, "count" => 1}]
assert_equal expected, test.group(["a"], {}, {"count" => 0}, "function (obj, prev) { prev.count++; }")
end end
def test_deref def test_deref