[SERVER-29512] Convert an ObjectId to a hex string in aggregation pipeline stages Created: 08/Jun/17  Updated: 06/Apr/23  Resolved: 02/Mar/18

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

Type: Improvement Priority: Major - P3
Reporter: Andrew Harris Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-33171 Add number and objectID parsing conve... Closed
Related
is related to SERVER-24947 Need a type conversion mechanism for ... Closed
Assigned Teams:
Query
Participants:

 Description   

At the moment if you need to concatenate two ObjectIds into a single string value then this has to be done outside AP (in Java code, etc).

What would be really handy is if there was so sort of $toString function that converts anything to a String representation or if you wanted to cut down the scope for now then expand the $concat function to internally convert ObjectIds to their hex string representation during the concat operation.



 Comments   
Comment by Asya Kamsky [ 02/Mar/18 ]

See this comment for how this will work:

https://jira.mongodb.org/browse/SERVER-22781?focusedCommentId=1821607&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-1821607

Comment by Andrew Harris [ 20/Dec/17 ]

So that will be 3.8 then? A long way off I suspect.

Comment by Asya Kamsky [ 08/Dec/17 ]

aharris yes, we are currently planning on delivering type conversion functionality (including this one) for the next major release.

Comment by Andrew Harris [ 08/Dec/17 ]

Is this improvement still be considered at all?

Comment by Samuel Marks [X] [ 06/Nov/17 ]

Agreed, my use-case I need to combine `ObjectId` for a new 'primary key'

Comment by Andrew Harris [ 26/Oct/17 ]

Any update on this?

I was hoping to see this as part of the 3.6 release changes.

Comment by Asya Kamsky [ 25/Jun/17 ]

aharris SERVER-24947 is meant to track conversion of ObjectId to various types (including from ObjectId to string or to date).

However, we are already considering specifically ObjectId to hex string since multiple MongoDB drivers provide that exact conversion function. We need to reach consensus on syntax for these type conversion functions and we are working on that now.

Comment by Andrew Harris [ 13/Jun/17 ]

More of an expansion on SERVER-24947 which appears to deal with the creation of ObjectId from a string rather than the creation of a hex String from an ObjectId in $project stages.

Comment by Dissatisfied Former User [ 12/Jun/17 ]

Potential duplicate of SERVER-24947 (type conversion for … ObjectID).

Comment by David Storch [ 08/Jun/17 ]

Hi aharris, thanks for the feature request. We are sending this request to the Query Team for triage.

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