Re: Edge case in the shell, repeated dots in a collection name

38 views
Skip to first unread message

Justin Dearing

unread,
Sep 23, 2012, 5:08:20 PM9/23/12
to mongodb-dev
Some final thoughts on this:

I have the following collections on my system:
  • EventLogs...Application
  • EventLogs...System
  • EventLogs...Windows PowerShell
  • EventLogs.ECH-BASE.Application
  • EventLogs.ECH-BASE.System
  • EventLogs.ECH-BASE.Windows PowerShell
I have three characters that would require the use of db.getCollection() (space, repeated dots and minus).
  • I don't see a need for repeated dots ever, and dot is a collection namespace separator by convention in mongodb. Therefore, I feel it should be forbidden to have repeating spaces in a collection name.
  • - is a javascript operator. At the same time dashes are often used in names that might become collection names. These should be kept
  • Spaces should also be allowed. I'm sure there are plenty of things in production that depend upon this.
What are everyone else;s thoughts?


On Sun, Sep 23, 2012 at 3:38 PM, Justin Dearing <jus...@mongodb.org> wrote:
Can we add -, and anything else that's not a valid property name in javascript to the list?

As I go through pandoras box, I'm thinking that perhaps people depend on this behavior and either use a GUI like mongobiew or db.getCollection().

Justin


On Sun, Sep 23, 2012 at 3:29 PM, Justin Dearing <jus...@mongodb.org> wrote:
Hi,

Due to a lack of error handling in my code I created a collection called EventLogs...Application. However, the shell naturally doesn't like db.EventLogs...Application.find(). Should the database allow creation of this collection name? Should the drivers not allow this? Let me know desired behavior and I shall open the appropiate bug(s).

Thanks,
Justin

My shell session:
C:\Users\zippy> mongo
MongoDB shell version: 2.0.7
connecting to: test
> show dbs
EventLogs       0.078125GB
csharpdriverunittests   0.078125GB
enron_mail      1.953125GB
local   (empty)
test    0.078125GB
> use EventLogs
switched to db EventLogs
> show collections
EventLogs...Application
system.indexes
> db.EventLogs...Application.find()
Sun Sep 23 15:21:49 SyntaxError: syntax error (shell):1
> db.EventLogs...Application.find()


Scott Hernandez

unread,
Sep 23, 2012, 5:14:02 PM9/23/12
to mongo...@googlegroups.com
For all these characters which can't be used in
javascript/whatever-lang (DSL) as db.coll_name.op() but you can use
the db["..."].op() or db.getCollection(" .. .. anything valid").op()
form.

There is a big difference in what javascript, or any dynamic languages
supports in that style, versus valid collection names. Each language
is going to place its own restriction in the DSL form, but not on the
collection name as a string.
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-dev" group.
> To post to this group, send email to mongo...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-dev...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-dev?hl=en.

Justin Dearing

unread,
Sep 23, 2012, 3:29:55 PM9/23/12
to mongodb-dev

Justin Dearing

unread,
Sep 23, 2012, 3:38:29 PM9/23/12
to mongodb-dev
Can we add -, and anything else that's not a valid property name in javascript to the list?

As I go through pandoras box, I'm thinking that perhaps people depend on this behavior and either use a GUI like mongobiew or db.getCollection().

Justin

On Sun, Sep 23, 2012 at 3:29 PM, Justin Dearing <jus...@mongodb.org> wrote:
Reply all
Reply to author
Forward
0 new messages