Skip to content

Model original state not isolated between different model types #1953

@petrmifek

Description

@petrmifek

Environment

playground

Reproduction

playground link

Describe the bug

/**
* Original model data.
*/
protected static original: Record<string, any> = {}

Current Behavior

The original static property in the Model class stores original states using only the model's ID as the key, causing different model types to overwrite each other's original states when they share the same ID.

Expected Behavior

Models of different types should maintain separate original states even when they share the same ID values. The $getOriginal() method should return the correct original state for each model type independently.

Proposed Solution

Namespace the original states by model entity.

Additional context

I suppose pinia-orm doesn't require the model instances primary keys to be unique across the whole DB, just each Model. Hopefully I didn't miss it... Thanks.

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions