Comments (5)
You're right. The test fails:
1) Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeTypeTest::testGettersReturnSameValuesAfterDatabaseRoundtrip
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-Binary String: 0xff6f8cb0c57d11e19b210800200c9a66
+Binary String: 0x11e1c57dff6f8cb09b210800200c9a66
I know it seems awkward, but this is how the OrderedTimeCodec
works.
When it decodes the bytes, it puts them back into the order specified by the RFC, but when you get the bytes (using getBytes()
) to put them into a database, it returns the bytes in the "ordered time" order, which rearranges the time fields, so that it can be stored in such a way that the table can be sorted by the UUIDs, and they'll be sorted in the order in which they were created.
What's happening in the test you've provided is that Uuid::fromString()
is creating a standard Uuid object. There's nothing special about it. So, when you call getBytes()
, they're in the proper order, as defined by the RFC. But when you pass that Uuid object into convertToDatabaseValue()
for the UuidBinaryOrderedTimeType, then it gets converted into a special type of Uuid, where the bytes are re-arranged for sorting by "ordered time." When you call convertToPHPValue()
for the same type, it maintains this special type and returns a Uuid object in which the return value of getBytes()
will always return the bytes in the "ordered time" format, even though the hex values a rendered properly, according to the RFC definition.
Does that help clear things up? If not, feel free to ask more questions.
from uuid-doctrine.
Well, you've just reiterated what I already stated in the initial bug report. Rehydrated UUID has a different codec, that affects its behavior (= 'converted into a special type of Uuid, where the bytes are re-arranged for sorting by "ordered time."'). It wasn't there before it hit the db, it doesn't need to be there when it gets back.
from uuid-doctrine.
It wasn't there before it hit the db, it doesn't need to be there when it gets back.
Iām not sure what this means.
When you use the UuidBinaryOrderedTimeType
, it converts the UUID into this special type. If you need the bytes to remain the same before and after, use the UuidBinaryType
instead to pass the UUID into the database and back.
from uuid-doctrine.
it converts the UUID into this special type.
Right. And it doesn't need to do that, as far as Doctrine type handling is concerned. Type converter gets binary string and returns a UUID. Which has no reason to be any kind of special sub-specie. Could have been ordinary UUID just as well, so it wouldn't be breaking storage transparency.
from uuid-doctrine.
The point of using the OrderedTimeCodec
is to rearrange the bytes in just this way.
from uuid-doctrine.
Related Issues (20)
- doctrine.yaml configuration issue HOT 1
- Type missmatch in generator with static PHP Mapping (LazyUuidFromString to property Uuid) HOT 3
- There is a bug in MariaDB 10.5.9, extremly slowing queris with UUID in binary form HOT 2
- uuid_binary_ordered_time not working with IN expression HOT 8
- Doctrine 3 compatibility HOT 1
- Imcompatible with the latest Doctrine 2.10 HOT 2
- doctrine.dbal.default_connection is set to 'default' and cannot be changed anymore HOT 2
- Deprecation notice after updating from Symfony 5.3 to 5.4 HOT 2
- Tag new release HOT 1
- Supportfor typed property. HOT 4
- Support other types of `EntityManagerInterface` too HOT 2
- Fetching metadata from an entity using the custom strategy is throwing an error. HOT 2
- Node of UUID is 0 HOT 1
- Additional usage of UUID v6/v7 for UuidBinaryOrderedTimeType HOT 7
- Converting my entities ids to uuids
- Tag a new release HOT 1
- Fetching association throws "Unknown parameter type, 116 given" exception HOT 6
- PostgreSQL UUID type returns a binary stream; DB to PHP conversion is always null HOT 5
- Object of class Ramsey\Uuid\Lazy\LazyUuidFromString could not be converted to int HOT 1
- Doctrine/dbal v4 is out!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uuid-doctrine.