Skip to content

mongo 6: cannot request a collection with a dot (".") in its name #146

@pierreMizrahi

Description

@pierreMizrahi

The following test case:

  describe "collectionWithDot" $ do
    it "uses a collection with dots in the name" $ do
      let coll = "collection.with.dot"
      _id <- db $ insert coll ["name" =: "jack", "color" =: "blue"]
      Just doc <- db $ findOne (select ["name" =: "jack"] coll)
      doc !? "color" `shouldBe` (Just "blue")

fails with mongo 6.0. It succeeds with versions that do not use OP_MSG, and succeeds if the dots are replaced by underscores in the collection name.

Collections with dot are supported by both the mongo client and the python client.

This is due to

let coll = last $ T.splitOn "." (qFullCollection qry)

Which returns the rightmost suffix.

I will submit a PR that only drops the prefix until the first dot. It should be safe because the mongo spec states that dtabase names should not contain a dot, both on windows and linux platforms:

https://www.mongodb.com/docs/manual/reference/limits/#naming-restrictions

Note that the doc does not give such restrictions on collection names, as only "$" and "system." are forbidden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions