8000 Updating a Pydantic model using Pydantic's `model_copy` errors when trying to save the copy · Issue #722 · geldata/gel-python · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Updating a Pydantic model using Pydantic's model_copy errors when trying to save the copy #722
Open
@scotttrinh

Description

@scotttrinh

Using a partial "update" Pydantic model to directly update an existing Gel model using the Pydantic model_copy mechanism fails.

class FooUpdate(BaseModel):
    name: str = "Anonymous"

def update_foo(client: gel.Client, foo_in: FooUpdate, foo: Foo):
    foo = foo.model_copy(
        update=foo_in.model_dump(exclude_unset=True)
    )
    await client.save(updated)

Will return an error like:

AttributeError: 'Foo' object has no attribute '__gel_changed_fields__'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0