MongoDb: After inserting a UUID with ruby, c# can't convert it to GUID -
MongoDb: After inserting a UUID with ruby, c# can't convert it to GUID -
i attempting insert object mongodb using ruby , retrieve using c# , norm driver.
all seemed progressing until wanted utilize guid within c# object.
i used next code set uuid in ruby before inserting mongo (as suggested blog post http://blog.mikeobrien.net/2010/08/working-with-guids-in-mongodb-with-ruby.html):
bson::binary.new("d7b73eed91c549bfaa9ea3973aa97c7b", bson::binary::subtype_uuid) when retrieving object in c# exception "byte array guid must 16 bytes long." thrown.
using administrative shell inspected contents of object. guid property had been set
bindata(3,"zddinznlzwq5mwm1ndlizmfhowvhmzk3m2fhotdjn2i=") however if inserted same guid using c# guid property set to
bindata(3,"7t6318wrv0mqnqoxoql8ew==") any ideas i'm doing wrong?
i think blog illustration wrong. looks me want guid hexstring, ie starting "\xd7" (one byte) not "d7"
i tried this:
guidpack=guid.scan(/../).map {|e| e.to_i(16)}.pack('c*') and checked base64 encoded size, looks right now.
base64.encode64 bson::binary.new(guidpack, bson::binary::subtype_uuid).to_s => "17c+7zhfsb+qnqoxoql8ew==\n" but result doesn't match happens when utilize c# above, might not right reply @ all. (i'm not testing mongo etc, bson gem, can't check sorry)
c# ruby mongodb uuid
Comments
Post a Comment