mgo icon indicating copy to clipboard operation
mgo copied to clipboard

Add support for aliased ObjectIds

Open dambrisco opened this issue 6 years ago • 6 comments

Resolves #98 by way of the discussed "objectid" tag.

Specifically, this PR adds support for aliasing []byte and string fields to and from ObjectIds. Other types are not supportable at this time, at least without fairly contrived scenarios like 3-length arrays of Int32, but adding support for other types in the future should be fairly easy if needed.

dambrisco avatar Apr 25 '19 20:04 dambrisco

~~Looks like I accidentally stomped on some code in a rebase, I'll get that fixed.~~

Fixed.

dambrisco avatar Apr 25 '19 20:04 dambrisco

I just saw this after I posted my PR :( https://github.com/globalsign/mgo/pull/357

ilius avatar May 02 '19 03:05 ilius

Yours is more flexible, but looks like it does not support string pointer, which is much more useful than array...

ilius avatar May 02 '19 03:05 ilius

@ilius It should be fairly straightforward to add string pointer support to my code. I can look into doing that within the next week.

dambrisco avatar May 02 '19 05:05 dambrisco

Oh crud! My PR is based on master, and looks like the upstream master is not merged into development for a while and there are conflicts!

I think we better pass info *fieldInfo argument (to addElem or readElemTo) instead of boolean, so that we don't have to keep adding arguments for each flag.

ilius avatar May 02 '19 06:05 ilius

Please take a look if you may: https://github.com/globalsign/mgo/pull/357 I'm closing my PR.

ilius avatar May 02 '19 06:05 ilius