[JAVA-2960] Document.parse and BasicDBObject.parse do not support 'Code' field Created: 04/Sep/18  Updated: 04/Jan/19  Resolved: 04/Jan/19

Status: Closed
Project: Java Driver
Component/s: JSON
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Vladimir Isakov (Inactive) Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends

 Description   

Document.parse and BasicDBObject.parse are able to parse document strings which have the extended json $code, however they are not able to parse the shell form 'Code'.



 Comments   
Comment by Jeffrey Yemin [ 04/Jan/19 ]

Based on my previous comment, closing as Won't Fix.

Comment by Jeffrey Yemin [ 29/Nov/18 ]

vladimir.isakov I don't see how we can fix this, since there doesn't seem to be a way to distinguish a BSON value of type code from a nested document with a single "code" field.

Comment by Vladimir Isakov (Inactive) [ 05/Sep/18 ]

jeff.yemin yes that is strange. Not sure why.

Comment by Jeffrey Yemin [ 05/Sep/18 ]

OK. It's odd the way the server represents BSON code type:

MongoDB Enterprise > d = {x: Code("any string")}
{ "x" : { "code" : "any string" } }

Instead of

MongoDB Enterprise > d = {x: Code("any string")}
{ "x" : { "$code" : "any string" } }

or

MongoDB Enterprise > d = {x: Code("any string")}
{ "x" :{x: Code("any string") }

Comment by Vladimir Isakov (Inactive) [ 05/Sep/18 ]

jeff.yemin I don't really know too much about it myself. I think it might be best to ask someone on the server team for documentation of the 'Code' shell type. All I know is that I'm able to go into the shell and insert, update, find and delete a document which has any field x that looks like this {..., x: Code("any string"), ...}. When I try to update or find that doc, I am able to query for it like this {x: Code("any string")}. So based on the fact that the shell allows this, I would think the java driver should be able to parse it. But I really don't know much about 'Code' so it would probably be best to speak with someone on the server team who does. The only documentation I've been able to find on it is the document you wrote: https://github.com/mongodb/specifications/blob/master/source/extended-json.rst#id42

Comment by Jeffrey Yemin [ 04/Sep/18 ]

Can you provide some examples that you would expect to work? Or links to documentation?

Thanks,
Jeff

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