[SERVER-19530] Add support for ES6 symbol type to shell and server-side JS Created: 22/Jul/15  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: 3.1.6
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kamran K. Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 1
Labels: 32qa, move-sa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Sprint: Dev Tools 2019-11-04
Participants:

 Description   

ES6 adds support for a symbol type. This type is not supported in our shell and server-side JS, even though SpiderMonkey provides native support:

// Shell
> db.foo.insert({a: Symbol()});
2015-07-22T15:17:17.176-0400 E QUERY    [thread1] Error: unable to convert JavaScript property to mongo element a :
Bulk/addToOperationsList@src/mongo/shell/bulk_api.js:600:22
Bulk/this.insert@src/mongo/shell/bulk_api.js:647:14
DBCollection.prototype.insert@src/mongo/shell/collection.js:256:13
@(shell):1:1
 
// Server-side JS
> db.eval('db.foo.insert({a: Symbol()});');
WARNING: db.eval is deprecated
2015-07-22T15:18:00.853-0400 E QUERY    [thread1] Error: {
	"ok" : 0,
	"errmsg" : "Error: unable to convert JavaScript property to mongo element a :\nBulk/addToOperationsList@src/mongo/shell/bulk_api.js:600:22\nBulk/this.insert@src/mongo/shell/bulk_api.js:647:14\nDBCollection.prototype.insert@src/mongo/shell/collection.js:256:13\n_funcs1@:1:30\n",
	"code" : 16662
} :
_getErrorWithCode@src/mongo/shell/utils.js:23:13
DB.prototype.eval@src/mongo/shell/db.js:542:1
@(shell):1:1



 Comments   
Comment by Gabriel Russell (Inactive) [ 05/Dec/19 ]

steven.vannelli I've confirmed that symbol support is unchanged post spider-monkey upgrade. Attempting to insert a symbol type results in the above error and failure.

Comment by Kamran K. [ 24/Jul/15 ]

Given the lack of support from drivers and the type deprecation, it may be better to just fail more gracefully than to add support for the ES6 symbol type.

Comment by Bernie Hackett [ 22/Jul/15 ]

I assume this would map to the (deprecated) BSON symbol type? If so, the problem with it is that you can't round trip that type through any drivers other than Ruby. Most other drivers convert the BSON symbol type to BSON string, losing type information.

Generated at Thu Feb 08 03:51:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.