Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-243

Collection options not inherited by collections with dotted names

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Accessing a collection with a dot in its name works thus in Motor:

      coll2 = collection.sub
      coll2 = collection["sub"]
      

      If "collection" has any customization to its options (read concern, write concern, read preference, codec options, ...) those options should be inherited by "coll2", but instead coll2 inherits from collection's MotorDatabase object.

      from pymongo import WriteConcern
      
      from motor import MotorClient
      
      
      coll = MotorClient().db.collection
      coll2 = coll.with_options(write_concern=WriteConcern(w=0))
      assert coll2.write_concern == WriteConcern(w=0)
      assert coll.write_concern != coll2.write_concern
      # Collection "collection.sub". Inherits write concern from db, not from coll2!
      coll3 = coll2.sub
      assert coll2.write_concern == coll3.write_concern  # Fails.
      

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: