Legal key names: key must not contain '.'

520 views
Skip to first unread message

Alex

unread,
Oct 26, 2012, 7:36:05 PM10/26/12
to mongod...@googlegroups.com, Nathan Stults
We have a MongoDB database, apparently having documents (or sub-documents) with keys that were combination of IP addresses and something else. We used to get error messages like "key xxxx must not contain '.'" with older version (1.1.x) of mongo db ruby driver (specifically bson and bson_ext), but we don't have such problem with later version (1.4.x and 1.5.x). Recently we want to update our gems to use the latest mongodb ruby driver (version 1.7.0), and the old problem comes back. To use the newer version of mongodb ruby drive, we had to scan all keys of documents to ensure such characters are swapped before saving and after receiving documents. Does any of you know the real difference between bson 1.4 and 1.7 that leads to such different behavior? Would it be more efficient to do such serializing/deserializing job using native c code?

Thanks,
Alex

Sam Millman

unread,
Oct 27, 2012, 6:20:35 AM10/27/12
to mongod...@googlegroups.com
Personally I would say that any fieldname with a .or $ should be avoided. it creates confusion for the querier to understand the difference between a update modifier and a document field.

I would store, as most people do, IPs in integer format.

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Reply all
Reply to author
Forward
0 new messages