You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
repository.create strips values of columns that are both arrays and embedded objects #1980
NOTE: I am using create because the class in which I'm performing the operation is generic, and I have no way of simply creating the entity instances using their constructors.
Reacted by Dave Lee and Michael Black Ritter
Reacted by Michael Black Ritter
Reacted by Michael Black Ritter
Reacted by Michael Black Ritter
Reacted by Michael Black Ritter and Olaleye Afolabi
If I use my original object, I can see that ColumnMetadata.isArray correctly indicates that collection is supposed to be an array, but then ColumnMetadata.getEntityValue goes ahead and simply ignores this, finally reaching line 559, at which point it attempts to extract the value directly from the array [ { "value": true } ], which results in an undefined value.
I can also confirm that the issue isn't reproducible when the array is not of embedded objects, but simple types. Embedded objects, however, work correctly, given that they are not also arrays. The following setups both work flawlessly:
changed the title [-]TypeORM strips array type column values when using `repository.create`[/-][+]`repository.create` strips values of columns that are both arrays and embedded objects[/+]on Apr 20, 2018
Activity
skreborn commentedon Apr 20, 2018
The following value passes through without a problem, although I don't think that's correct behavior.
{ "simple": "string", "collection": { "value": true } }If I use my original object, I can see that
ColumnMetadata.isArraycorrectly indicates thatcollectionis supposed to be an array, but thenColumnMetadata.getEntityValuegoes ahead and simply ignores this, finally reaching line 559, at which point it attempts to extract the value directly from the array[ { "value": true } ], which results in an undefined value.skreborn commentedon Apr 20, 2018
I can also confirm that the issue isn't reproducible when the array is not of embedded objects, but simple types. Embedded objects, however, work correctly, given that they are not also arrays. The following setups both work flawlessly:
Which means that the problem occurs only if a column is both an array and an embedded object.
[-]TypeORM strips array type column values when using `repository.create`[/-][+]`repository.create` strips values of columns that are both arrays and embedded objects[/+]thonythony commentedon Jun 13, 2018
Hello,
I have the same issue (my column is both an array and an embedded object).
@skreborn, @pleerock have you a workaround using repository.create() ?
Thanks
mblackritter commentedon Oct 1, 2019
Luckily, a simple workaround is described here: https://stackoverflow.com/a/54816132/3804973
IbrahimAdDandan commentedon Dec 16, 2021
and yes, Still behaving incorrectly :(
luckv commentedon Dec 23, 2021
I also have this issue. Any plan on this?
uzenith360 commentedon May 22, 2022
This is still a problem