minor: allow oplog. collection
This commit is contained in:
parent
4550389480
commit
f0766c9d2e
@ -33,8 +33,8 @@ module Mongo
|
|||||||
if name.empty? or name.include? ".."
|
if name.empty? or name.include? ".."
|
||||||
raise InvalidName, "collection names cannot be empty"
|
raise InvalidName, "collection names cannot be empty"
|
||||||
end
|
end
|
||||||
if name.include? "$" and not name.match(/^\$cmd/)
|
if name.include? "$"
|
||||||
raise InvalidName, "collection names must not contain '$'"
|
raise InvalidName, "collection names must not contain '$'" unless name =~ /((^\$cmd)|(oplog\.\$main))/
|
||||||
end
|
end
|
||||||
if name.match(/^\./) or name.match(/\.$/)
|
if name.match(/^\./) or name.match(/\.$/)
|
||||||
raise InvalidName, "collection names must not start or end with '.'"
|
raise InvalidName, "collection names must not start or end with '.'"
|
||||||
|
@ -26,11 +26,20 @@ class TestCollection < Test::Unit::TestCase
|
|||||||
assert @coll.pk_factory.is_a?(Object)
|
assert @coll.pk_factory.is_a?(Object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_collection
|
def test_valid_names
|
||||||
assert_raise InvalidName do
|
assert_raise InvalidName do
|
||||||
@@db["te$t"]
|
@@db["te$t"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_raise InvalidName do
|
||||||
|
@@db['$main']
|
||||||
|
end
|
||||||
|
|
||||||
|
assert @@db['$cmd']
|
||||||
|
assert @@db['oplog.$main']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_collection
|
||||||
assert_kind_of Collection, @@db["test"]
|
assert_kind_of Collection, @@db["test"]
|
||||||
assert_equal @@db["test"].name(), @@db.collection("test").name()
|
assert_equal @@db["test"].name(), @@db.collection("test").name()
|
||||||
assert_equal @@db["test"].name(), @@db[:test].name()
|
assert_equal @@db["test"].name(), @@db[:test].name()
|
||||||
|
Loading…
Reference in New Issue
Block a user