[SERVER-29953] Numeric collection name Created: 02/Jul/17  Updated: 03/Jul/17  Resolved: 03/Jul/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Joel Mamedov Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13791 Cannot access collection 2001_ABC Closed
Participants:

 Description   

At the shell count() or find() returns error (see below) when referencing collection that named with numeric value. But, as a test created alphanumeric collection name and no errors

db.3330.find();
2017-07-02T18:32:05.050-0500 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:2

3330.count()
2017-07-02T18:30:49.350-0500 E QUERY [thread1] SyntaxError: identifier starts immediately after numeric literal @(she

> db.opp_3330.count();
1



 Comments   
Comment by Stennie Steneker (Inactive) [ 03/Jul/17 ]

Hi Joel,

This is expected behaviour for collection names that are not valid JavaScript identifiers.

You can reference those in the mongo shell using db.getCollection(name), eg:

db.getCollection('3330').find()
db.getCollection('3330').count()

Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag.

Regards,
Stephen

Generated at Thu Feb 08 04:22:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.