Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy attributes back post de-serializing array #451

Merged

Conversation

mgranell
Copy link
Contributor

@mgranell mgranell commented Jun 6, 2021

Fixes #450

@ghost
Copy link

ghost commented Jun 6, 2021

CLA assistant check
All CLA requirements met.

const arrayInstance = serializer.deserialize(propertyMapper, propertyInstance, propertyObjectName);
// Copy over any properties that have already been added into the instance, where they do
// not exist on the newly de-serialized array
Object.entries(instance).forEach(([key, value]) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
Object.entries(instance).forEach(([key, value]) => {
for (const [key, value] of Object.entries(instance)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated

@ramya-rao-a
Copy link
Contributor

@jeremymeng, @xirzec Do we have a similar issue in @azure/core-http or the newer Azure Core packages?

@jeremymeng
Copy link
Member

@jeremymeng, @xirzec Do we have a similar issue in @azure/core-http or the newer Azure Core packages?

I am looking into it.

jeremymeng added a commit to jeremymeng/azure-sdk-for-js that referenced this pull request Jun 9, 2021
Porting fix from Azure/ms-rest-js#451.

When flattening array, we were assigning directly to the result
instance, thus losing any properties that were deserialized previously
in the loop.  The fix is to copy the existing properties over.

Fixes Azure#15653.
@jeremymeng
Copy link
Member

@deyaaeldeen @xirzec are you good with the fix?

Copy link
Member

@deyaaeldeen deyaaeldeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@deyaaeldeen deyaaeldeen merged commit 062829a into Azure:master Jun 10, 2021
jeremymeng added a commit to Azure/azure-sdk-for-js that referenced this pull request Jun 10, 2021
…ion (#15655)

Porting fix from Azure/ms-rest-js#451.

When flattening array, we were assigning directly to the result
instance, thus losing any properties that were deserialized previously
in the loop.  The fix is to copy the existing properties over.

Fixes #15653.
sadasant pushed a commit to sadasant/azure-sdk-for-js that referenced this pull request Jun 21, 2021
…ion (Azure#15655)

Porting fix from Azure/ms-rest-js#451.

When flattening array, we were assigning directly to the result
instance, thus losing any properties that were deserialized previously
in the loop.  The fix is to copy the existing properties over.

Fixes Azure#15653.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array flattening in deserializer loses previously de-serialized attributes
5 participants