Skip to content

Bugfix/updating nested models - #139

Merged
Samwel K. (samwelkanda) merged 5 commits into
mainfrom
bugfix/updating-nested-models
Sep 15, 2023
Merged

Samwel K. (samwelkanda) merged 5 commits into
mainfrom
bugfix/updating-nested-models

Conversation

@samwelkanda

@samwelkanda Samwel K. (samwelkanda) commented Sep 15, 2023 •

Copy link
Copy Markdown
Contributor

Fixes error where updating an attribute of a nested backed model marks all other attributes as changed.

Example: Updating a recipient email address marks all other attributes of the recipient name and odata_type as changed.

async def update_message():
    updated = Message()
    recepients = Recipient()
    email_address = EmailAddress()
    email_address.address = "example@contoso.com"

    recepients.email_address = email_address
    updated.to_recipients = [recepients]
    

     msg = await (client.users.by_user_id(USER_ID )
                     .messages.by_message_id(MESSAGE_ID)
                     .patch(message))    	
asyncio.run(update_message())

Response: ODataError: A null value was found for the property named '@odata.type', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.

Solution:
Set is_initialization_completed property in nested backed models to True so that only changed values are marked as dirty.

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

2 participants