Open alcaeus opened 4 years ago
Hi, Any news regarding this issue? I see the same error in version 2.1.2
I had lost track of this issue. I wanted to revisit this yesterday, but with travis-ci no longer reliably running our builds I had to prioritise moving the build environment. I'll pick this up once CI is stable again, but if you want to take a shot at fixing this, please do.
The problem is the representation of string. uuid is passed as "string of hex" and not "hex string", "ab" = 16 bits not 8 bits, so the value is 32 bytes long instead the 16 bytes long (128 bits) attended size. using this "dirty" code in convertToDatabaseValue in BinDataType.php solve the problem
$str = $value;
if (strlen($value) == 32){
$str = '';
for($i=0;$i<strlen($value);$i+=2){
$str.=chr(hexdec(substr($value,$i,2)));
}
}
if (! $value instanceof Binary) {
return new Binary($str, $this->binDataType);
}
As a general rule, you shouldn't make such changes in the type itself, but rather in the code that generates the UUID. I just haven't gotten around to making the change and probably won't have the time to do so in the foreseeable future. If you're interested in working on this, I'm happy to help out.
Is there any progress on this issue?
Given the lack of updates here, I'd say "obviously not".
Bug Report
Summary
Given an identifier using
strategy="uuid"
andtype="bin_uuid"
ortype="bin_uuid_rfc4122"
, an error occurs when trying to store data:Expected behavior
The UUID generator should be able to generate UUIDs for consumption with the binary BSON types for UUIDs.