[SERVER-3229] Special Characters in Property Names Created: 09/Jun/11 Updated: 08/Dec/17 Resolved: 09/Jun/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Tom Wardrop | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | syntax | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Participants: |
| Description |
|
I'd like to see mongodb add support for special characters in field names. By special characters, I'm referring to the ascii classics such as ?, !, #, @, %, ^, and *. If that list is a bit daunting, then the main use case I have involves the question mark. In Ruby, as you may know, names, such method or variable names, can end in a question mark. The purpose of the question mark ties into the language slightly, but once you get use to and use some other data system which doesn't support the question mark, you really miss its expressiveness. In Ruby, if the convention is followed, it tells you at a glance if a name represents a predicate (true or false), or some other data. If your thinking a simple question mark serves no other purpose than offering syntactic sugar, think again, as it's semantic power shouldn't be underestimated. Here are some examples: paid: 'Credit Card' red?: false I'm not suggesting you'd ever use near identical property names like that, but it highlights how the property names 'paid' and 'red' can each represent completely different types of data, and how the use of the question mark can clarify the properties meaning or context. It sure beats the likes of 'has_paid' and 'is_red'. It's a shame that special characters are so feared in the world of syntax. I'd just ask that including the question mark, if not other special characters, be considered. |
| Comments |
| Comment by Roman Kuzmin [ 08/Dec/17 ] |
|
In 3.6 it seems to be possible to add fields with a dot. Is this by design? Example (works): db.test.update({y : {y : {"bad.1" : 1}}}, {$setOnInsert : {x : 42}}, {upsert : true}) |
| Comment by Ilan Biala [ 30/Jan/15 ] |
|
I just tried using the character "." in the field name, and it didn't work. Has this been decided as a wontfix, or just not enough need, or something else? |
| Comment by Tom Wardrop [ 10/Jun/11 ] |
|
Well that's embarrassing. Premature ejac... issuisation. |
| Comment by Scott Hernandez (Inactive) [ 09/Jun/11 ] |
|
You can use any (UTF8) character in the field name which aren't special (contains ".", or starts with "$"). > db.names.insert({_id:1, "test?":1}) |