FAQ

[mongodb-user] why dots in field names are illegal??

Dániel Boros
Nov 27, 2011 at 12:43 pm
Error: uncaught exception: can't have . in field names

I want to store JSON CSS (http://code.google.com/p/json-css/) in my
db, but the shell won't let me.
I know that originally this feature to deny dots was not in mongo db
so is there any way to turn it off?
As far as I know any character in a field name is valid JSON, so it
sohuld be also valid BSON.

I know that the dot has a special meaning in mongodb, but I don't
think it would neccesarly mess up the db if used correctly.
It should be left for the user to decide what he wants to use as field
names and live with the councequences. A shell warning may be
appropriate though.

Daniel

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
reply

Search Discussions

4 responses

  • Andreas Jung at Nov 27, 2011 at 12:54 pm

    Dániel Boros wrote:
    Error: uncaught exception: can't have . in field names

    I want to store JSON CSS (http://code.google.com/p/json-css/) in my
    db, but the shell won't let me. I know that originally this feature
    to deny dots was not in mongo db so is there any way to turn it off?
    As far as I know any character in a field name is valid JSON, so it
    sohuld be also valid BSON.
    Dots are used as separators for embedded documents. If you have
    keys with dots inside then escape then within your application _yourself_.

    - -aj
    - --
    ZOPYX Limited | zopyx group
    Charlottenstr. 37/1 | The full-service network for Zope & Plone
    D-72070 Tübingen | Produce & Publish
    www.zopyx.com | www.produce-and-publish.com
    - ------------------------------------------------------------------------
    E-Publishing, Python, Zope & Plone development, Consulting




    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Sam Millman at Nov 27, 2011 at 1:39 pm
    Using dots in any fields names in most DBs is kinda bad practice really,
    you shuld only use lower case alphanumeric separated by underscores.
    On 27 November 2011 12:54, Andreas Jung wrote:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1



    Dániel Boros wrote:
    Error: uncaught exception: can't have . in field names

    I want to store JSON CSS (http://code.google.com/p/json-css/) in my
    db, but the shell won't let me. I know that originally this feature
    to deny dots was not in mongo db so is there any way to turn it off?
    As far as I know any character in a field name is valid JSON, so it
    sohuld be also valid BSON.
    Dots are used as separators for embedded documents. If you have
    keys with dots inside then escape then within your application _yourself_.

    - -aj
    - --
    ZOPYX Limited | zopyx group
    Charlottenstr. 37/1 | The full-service network for Zope & Plone
    D-72070 Tübingen | Produce & Publish
    www.zopyx.com | www.produce-and-publish.com
    - ------------------------------------------------------------------------
    E-Publishing, Python, Zope & Plone development, Consulting




    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Tyler Brock at Nov 27, 2011 at 8:53 pm
    It's because a dot (".") signifies a sub-collection in mongodb. For
    example "blog.posts"

    You could get around this by writing a function that substitutes the
    dots for a legal character before insertion and another to convert it
    back on the way out of the database.

    -Tyler
    On Nov 27, 8:39 am, Sam Millman wrote:
    Using dots in any fields names in most DBs is kinda bad practice really,
    you shuld only use lower case alphanumeric separated by underscores.

    On 27 November 2011 12:54, Andreas Jung wrote:






    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1
    Dániel Boros wrote:
    Error:  uncaught exception: can't have . in field names
    I want to store JSON CSS (http://code.google.com/p/json-css/) in my
    db, but the shell won't let me. I know that originally this feature
    to deny dots was not in mongo db so is there any way to turn it off?
    As far as I know any character in a field name is valid JSON, so it
    sohuld be also valid BSON.
    Dots are used as separators for embedded documents. If you have
    keys with dots inside then escape then within your application _yourself_.
    - -aj
    - --
    ZOPYX Limited           | zopyx group
    Charlottenstr. 37/1     | The full-service network for Zope & Plone
    D-72070 Tübingen        | Produce & Publish
    www.zopyx.com          |www.produce-and-publish.com
    - ------------------------------------------------------------------------
    E-Publishing, Python, Zope & Plone development, Consulting

    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Tyler Brock at Nov 27, 2011 at 8:55 pm
    Whoops, Andreas was correct, it's an embedded document separator as
    well (which applies in this case).

    Sorry for the confusion.

    -Tyler
    On Nov 27, 3:53 pm, Tyler Brock wrote:
    It's because a dot (".") signifies a sub-collection in mongodb. For
    example "blog.posts"

    You could get around this by writing a function that substitutes the
    dots for a legal character before insertion and another to convert it
    back on the way out of the database.

    -Tyler

    On Nov 27, 8:39 am, Sam Millman wrote:






    Using dots in any fields names in most DBs is kinda bad practice really,
    you shuld only use lower case alphanumeric separated by underscores.
    On 27 November 2011 12:54, Andreas Jung wrote:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1
    Dániel Boros wrote:
    Error:  uncaught exception: can't have . in field names
    I want to store JSON CSS (http://code.google.com/p/json-css/) in my
    db, but the shell won't let me. I know that originally this feature
    to deny dots was not in mongo db so is there any way to turn it off?
    As far as I know any character in a field name is valid JSON, so it
    sohuld be also valid BSON.
    Dots are used as separators for embedded documents. If you have
    keys with dots inside then escape then within your application _yourself_.
    - -aj
    - --
    ZOPYX Limited           | zopyx group
    Charlottenstr. 37/1     | The full-service network for Zope & Plone
    D-72070 Tübingen        | Produce & Publish
    www.zopyx.com         |www.produce-and-publish.com
    - ------------------------------------------------------------------------
    E-Publishing, Python, Zope & Plone development, Consulting
    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Related Discussions

Discussion Navigation
viewthread | post