Open Aleeexx opened 3 years ago
Further investigation showed, the specific load*()
methods (like loadForOneToManyAndOneToOneNotOwner
etc.) from the RelationIdLoader
try to match the child entity with a parent entity by on the one hand the relationIds
and on the other the relatedEntities
, which are fetched by getRawMany()
.
The entries of the relationIds
array do have still have the ID as a buffer (RowDataPacket)
but the IDs of the entries of the relatedEntities
array were transformed back into an uuid (Instantiated entities).
So, the comparison will never successfully match for related Entities and therefore related will always be undefined.
Issue Description
Until yesterday all of our entities had an integer id. Now, some of them do have an UUID instead. So, their id property is of type string and saved in a BIN(16) column. In order to query an UUID entity, we need to transform the UUID string into a Buffer. Sadly TypeORM does not do that on querying relations (having a binary id) but we can work around that by, among other places, using a transformer in the entity.
Since we do use a DataLoader, we use
RelationIdLoader#loadManyToManyRelationIdsAndGroup
to perform batch loading.Expected Behavior
Using
RelationIdLoader#loadManyToManyRelationIdsAndGroup
should give us the related entities of the given UUID entities, as it still works for entities with an integer id (not needing a transformer).Actual Behavior
The
related
property ofRelationIdLoader#loadManyToManyRelationIdsAndGroup
`s return value is undefined for every entity, since the transformer is not applied for the ids (see first comment in this issue).My Environment
Relevant Database Driver(s)
MariaDB
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?