[JAVA-794] Java driver fails to detect fields with dots (.) under certain circumstances Created: 27/Mar/13  Updated: 02/Jul/13  Resolved: 25/Jun/13

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.9.2, 2.10.1
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Caleb Jones Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

$ java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-10M4203)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode)


Issue Links:
Duplicate
duplicates JAVA-820 DBCollection Doesn't Check Keys Conta... Closed
is duplicated by JAVA-789 Dots allowed in field names of object... Closed

 Description   

Using the java driver (I tried 2.9.2 and 2.10.1), I am able to create a document with field names with dots (.) in them.

Document:

{
  "_document_" : {
    "subdoc1" : {
      "subdoc2" : [
        {
          "field.with.dots" : {}
        }
      ]
    }
  }
}

(note I've stripped out some other fields which I believe are irrelevant to this bug, but let me know if this example does not reproduce for you)

If, however, I try to create this document from the Mongo shell, it properly detects the field with dots and returns an error:

> db.dots.insert({"_document_":{"field1_1":{"field1_1_1":[{"field.with.dots":{}}]}}})
Wed Mar 27 13:01:05 uncaught exception: can't have . in field names [field.with.dots]



 Comments   
Comment by auto [ 02/Jul/13 ]

Author:

{u'username': u'trnl', u'name': u'Uladzimir Mihura', u'email': u'trnl.me@gmail.com'}

Message: test(driver-compat) add tests from JAVA-794
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/542d99570d002e8b07f11c190a63f9a706e0ea78

Comment by Caleb Jones [ 08/May/13 ]

I've fixed this and created a pull request.

Comment by Caleb Jones [ 27/Mar/13 ]

My preference would be that all extra validation beyond BSON is done server-side and client libraries just worry about sending valid BSON (see SERVER-7150) but I understand the trade-offs in doing so.

Comment by Jeffrey Yemin [ 27/Mar/13 ]

It looks like com.mongodb.DBCollection#_checkKeys does not recurse through List, only Map. Good catch.

Comment by Caleb Jones [ 27/Mar/13 ]

I've gotten this narrowed down to:

{
  "_document_" : {
    "array" : [ {"my.dot.field" : "foo"}]
  }
}

Generated at Thu Feb 08 08:53:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.