Closed rshmhrj closed 2 years ago
Hi Rishi! Thanks for opening this issue :-)
Do you know why the 24-character string is rejected by MongoDB? From the discussions I'm reading online it would seem that any 24-character hex string should be good enough.
@FWDekker thanks for the quick response! Just tried it again and seems like Mongo is accepting the string surrounded by ObjectId()
The first one was inserted without setting the _id
and the last two were set with Randomness
Maybe previous tests didn't work because the max was 25 or 26. Setting both min and max to 24 seems to work.
Question -- would it be possible to adjust this feature request to include the prefix / postfix?
e.g. if "839193f9c6ef2aa4e9611c31"
is generated by Randomness, have an option to turn the output into ObjectId("839193f9c6ef2aa4e9611c31")
? I tried playing with the brackets in the Symbol Sets and that just adds them randomly to the output.
Sure, I can add a prefix/postfix option for strings :-) I'll try to do that this week.
It took me a bit longer than expected because I had to update a bunch of dependencies in the v2 branch which caused all sorts of issues because the latest versions of those dependencies just so happened to have critical bugs...
Anyway, this issue has been resolved in 9c335d19c5959e8df7e51563a56846edc6456c4d, and will be available in v2.7.5 through the ability to add a prefix and postfix to strings. You'll be able to update the plugin in your IDE in a few days, but if you cannot wait until then you can always download intellij-randomness-2.7.5.zip
from the latest release and install the plugin from disk.
Thanks for reporting this issue! Please tell me if you have any further questions or remarks :-)
Problem Currently using Randomness to help generate GUIDS in the UUID format for unit tests / test data. Would like to extend it to autogenerate ObjectIds (similar to the output here). Tried creating a new scheme within String settings to create a format that looks like an ObjectID:
This generates an okay looking String but it doesn't get accepted as a valid ObjectId when inserting into Mongo.
Suggested solution Create 6th section for ObjectIds
Alternative solutions Add as an option within the UUID section
Additional context Would also be nice to have the following options:
ObjectId(
and postfix with)