[DOCS-12043] Misleading dot and dollar field name advice Created: 10/Sep/18  Updated: 29/Oct/23  Resolved: 11/Sep/18

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Scott L'Hommedieu (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by DOCS-11414 Inconsistency about whether dotted fi... Closed
Related
is related to DOCS-11414 Inconsistency about whether dotted fi... Closed
is related to DRIVERS-618 Add escaping convention for dot and d... Closed
Participants:
Days since reply: 5 years, 22 weeks, 1 day ago
Epic Link: DOCSP-1769

 Description   

Description

Although server now allows . and $ in field names none of the drivers support these characters in field names.  The documentation is misleading and may cause users to use these characters without knowing they will not be able to access these collections or fields with the drivers.

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Kay Kim (Inactive) [ 11/Sep/18 ]

no worries

Comment by Bernie Hackett [ 11/Sep/18 ]

That is a big improvement. Thanks Kay.

Comment by Githook User [ 11/Sep/18 ]

Author:

{'name': 'kay', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12043: field name restriction clarification
Branch: v3.6
https://github.com/mongodb/docs/commit/b13ef371a02732bb85d80e9a52bd0c9845107dc2

Comment by Githook User [ 11/Sep/18 ]

Author:

{'name': 'kay', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-12043: field name restriction clarification
Branch: master
https://github.com/mongodb/docs/commit/5f2d5e7dce7766a14b25b0d032970f065a866110

Comment by Bernie Hackett [ 11/Sep/18 ]

So we're all on the same page, here's a trivial example of the problem:

>>> c.foo.command('insert', 'bar', documents=[{'foo.bar': 'foobar'}])
{'n': 1, 'ok': 1.0}
>>> c.foo.bar.find_one()
{'_id': ObjectId('5b97d5d32862bc21419f4bbc'), 'foo.bar': 'foobar'}
>>> c.foo.bar.find_one({'foo.bar': 'foobar'})
>>>

We added these restrictions to drivers years ago because of the bitter complaints we got from users who found themselves unable to query on fields like this.

As for $ in keys, AFAIK drivers only reject keys that start with $, which the server also rejects:

>>> c.foo.command('insert', 'bar', documents=[{'$set': 'foobar'}])
{'n': 0, 'writeErrors': [{'index': 0, 'code': 2, 'errmsg': "Document can't have $ prefixed field names: $set"}], 'ok': 1.0}

Comment by Asya Kamsky [ 11/Sep/18 ]

Why is this ticket separate from DOCS-11414?

And there is a way to query for these fields just not very simple/obvious way.

Comment by Scott L'Hommedieu (Inactive) [ 11/Sep/18 ]

asya do you have an opinion here?

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