New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange UUID Bson serialization behavior #2161

Closed
tchaloupka opened this Issue May 11, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@tchaloupka
Contributor

tchaloupka commented May 11, 2018

This test fails:

unittest
{
	UUID uuid = UUID("35399104-fbc9-4c08-bbaf-65a5efe6f5f2");

	auto bson = Bson(uuid);
	assert(bson.get!UUID == uuid);
	assert(bson.deserializeBson!UUID == uuid);

	bson = Bson([Bson(uuid)]);
	assert(bson.deserializeBson!(UUID[]) == [uuid]);
}

on assert(bson.deserializeBson!UUID == uuid); with:

object.Exception@data/vibe/data/bson.d(1512): Expected object instead of binData
----------------
/usr/include/dmd/phobos/std/exception.d:514 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0x64a756]
/usr/include/dmd/phobos/std/exception.d:435 pure @safe bool std.exception.enforce!().enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x64a966]
data/vibe/data/bson.d:1512 @safe void vibe.data.bson.BsonSerializer.readDictionary!(vibe.data.serialization.Traits!(std.uuid.UUID, vibe.data.serialization.DefaultPolicy).Traits).readDictionary(scope void delegate(immutable(char)[]) @safe) [0x5d75b5]
data/vibe/data/serialization.d:773 @safe std.uuid.UUID vibe.data.serialization.deserializeValueImpl!(vibe.data.bson.BsonSerializer, vibe.data.serialization.DefaultPolicy).deserializeValueDeduced!(std.uuid.UUID).deserializeValueDeduced(ref vibe.data.bson.BsonSerializer) [0x650d39]
data/vibe/data/serialization.d:576 @safe std.uuid.UUID vibe.data.serialization.deserializeValueImpl!(vibe.data.bson.BsonSerializer, vibe.data.serialization.DefaultPolicy).deserializeValue!(std.uuid.UUID).deserializeValue(ref vibe.data.bson.BsonSerializer) [0x650cdc]
data/vibe/data/serialization.d:299 @safe std.uuid.UUID vibe.data.serialization.deserializeWithPolicy!(vibe.data.bson.BsonSerializer, vibe.data.serialization.DefaultPolicy, std.uuid.UUID, vibe.data.bson.Bson).deserializeWithPolicy(vibe.data.bson.Bson) [0x650cad]
data/vibe/data/serialization.d:265 @safe std.uuid.UUID vibe.data.serialization.deserialize!(vibe.data.bson.BsonSerializer, std.uuid.UUID, vibe.data.bson.Bson).deserialize(vibe.data.bson.Bson) [0x650c45]
data/vibe/data/bson.d:1168 @safe std.uuid.UUID vibe.data.bson.deserializeBson!(std.uuid.UUID).deserializeBson(vibe.data.bson.Bson) [0x5d753d]

Because UUID is handled as object in bson serialization for some reason.
Is it supposedly correct behavior or bug?

tchaloupka added a commit to tchaloupka/dpq2 that referenced this issue May 11, 2018

Add support for UUID array values
Found some strange behavior with vibe-d bson serialization while testing this.
UUID[] can't be deserialized from Bson as is read from the PG.
So I changed the read value to be deserializable and created an issue here: vibe-d/vibe.d#2161

@s-ludwig s-ludwig closed this in fa5aa0a May 18, 2018

s-ludwig added a commit that referenced this issue May 18, 2018

Merge pull request #2163 from tchaloupka/fix2161
fix #2161 - bson UUID serialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment