Skip to content
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

tchaloupka opened this issue May 11, 2018 · 0 comments

Strange UUID Bson serialization behavior #2161

tchaloupka opened this issue May 11, 2018 · 0 comments


Copy link

@tchaloupka tchaloupka commented May 11, 2018

This test fails:

	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!(!(std.uuid.UUID, void delegate(immutable(char)[]) @safe) [0x5d75b5]
data/vibe/data/serialization.d:773 @safe std.uuid.UUID!(,!(std.uuid.UUID).deserializeValueDeduced(ref [0x650d39]
data/vibe/data/serialization.d:576 @safe std.uuid.UUID!(,!(std.uuid.UUID).deserializeValue(ref [0x650cdc]
data/vibe/data/serialization.d:299 @safe std.uuid.UUID!(,, std.uuid.UUID, [0x650cad]
data/vibe/data/serialization.d:265 @safe std.uuid.UUID!(, std.uuid.UUID, [0x650c45]
data/vibe/data/bson.d:1168 @safe std.uuid.UUID!(std.uuid.UUID).deserializeBson( [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
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
fix #2161 - bson UUID serialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.