Skip to content

Preventing dot "." in keys breaks existing applications. - #162

Closed
mathusiast wants to merge 2 commits into
mongodb:masterfrom
mathusiast:master
Closed

mathusiast wants to merge 2 commits into
mongodb:masterfrom
mathusiast:master

Conversation

@mathusiast

Copy link
Copy Markdown

Consider the large install base of mongo, and the fact many have used it while this was quite "legal" to use a string for a key that contains "." within, I think making it "illegal" is simply wrong, given the fact data current databases with dots in keys are either forced to use old driver, or change keys which nearly impossible.

Given the fact mongo itself, as a database, works just fine with it, it would just sane to make this constrain configurable, letting users decide whether or not their keys will contain a dot.

This is my current code, where this exception raising is commented out in both places.

Tzury Bar Yochay added 2 commits March 8, 2013 12:56
This shall be an optional config parameter, but having this 
constraint hard-coded, makes current apps which worked with 
previous versions without issue, break.
This shall be an optional config parameter, but having this 
constraint hard-coded, makes current apps which worked with 
previous versions without issue, break.
@ajdavis

ajdavis commented Mar 8, 2013

Copy link
Copy Markdown
Member

We are trying very hard to protect current users from inserting data into MongoDB with dots and dollars in field names—such field names are poorly supported and extremely difficult to work with. Meanwhile, you can pass check_keys=False to insert, update, and save to support your current schema.

@ajdavis ajdavis closed this Mar 8, 2013
@mathusiast

Copy link
Copy Markdown
Author

was not aware of this check_keys=False option.
thanks,
While $name makes perfectly sense, having a dot is way different becomes an issue only if one use dot notation rather than strings, i.e. doc._id rather than doc["_id"].

However, there are zillions of cases where the dot is an organic part of a data item, which makes it perfect candidate for a key, e.g.

"example.com/index.html":  { ... }
"v1.1" :  { ... }
"package.module.function"

and so on and so forth.

The check_keys=False is a very good solution for me. However, I would suggest not treating $key and ke.y the same way.

Thanks a million for the mongo, pymongo, and Motor by the way.
It is a great pleasure working with those tools.

@ajdavis

ajdavis commented Mar 9, 2013

Copy link
Copy Markdown
Member

We prevent dots because in most circumstances, it makes querying on those
fields hard. Glad check-keys works for you!

On Saturday, March 9, 2013, Tzury Bar Yochay wrote:

was not aware of this check_keys=False option.
thanks,
While $name makes perfectly sense, having a dot is way different becomes
an issue only if one use dot notation rather than strings, i.e. doc._id
rather than doc["_id"].

However, there are zillions of cases where the dot is an organic part of a
data item, which makes it perfect candidate for a key, e.g.

"example.com/index.html": { ... }
"v1.1" : { ... }
"package.module.function"

and so on and so forth.

The check_keys=False is a very good solution for me. However, I would
suggest not treating $key and ke.y the same way.

Thanks a million for the mongo, pymongo, and Motor by the way.
It is a great pleasure working with those tools.

—
Reply to this email directly or view it on GitHubhttps://github.com//pull/162#issuecomment-14659337
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants