Closed basz closed 1 year ago
Usually this happens if some of the objects are cyclicly referenced. Can you verify they aren't?
ai, i don't know. I think TypeORM return simple pojo's for entities? The data structure itself isn't for sure.
A user has many org-member rows, and an org-member row can reference the same org for different users, but not in this example...
Looking at the missing objects, you can see they use the same ID, so it's definitely a cycle problem. TypeORM is probably intelligent enough to cache based on identity which is causing this problem.
@egmacke Do you know a workaround?
@basz apologies for not seeing this sooner - I had my first kid at the start of April so been a bit busy, and finally catching up with things!
I'll have a look into this for you - however it would be really useful if you could provide a repo with a simple replication of the issue (I've not worked with TypeORM before)
weird, that is code from jsonapi-serializer i was playing with... sorry...
Describe the bug*
Serializing an array of entities from TupeORM with some nested includes only works if I JSON.parse(JSON.stringify(entities)) first.
To Reproduce*
this does not include the organisation
const serializedData = serializer.serialize(data);
but this one does
const serializedData = serializer.serialize(JSON.parse(JSON.stringify(data));
Expected behavior*
I would expect the include property would include the organisation regardless.
Platform*
"@nestjs/typeorm": "^9.0.1", "typeorm": "^0.3.11",
"ts-japi": "^1.8.0",
Additional context
It could be that I should do something to get TypeORM to play along.
My entities contain the following;
log without JSON.stringify
log with JSON.stringify