Skip to content

Inconsistent Data Access for CRUD Results #183

@radish-bit

Description

@radish-bit

Hi,

In the API endpoints, for example within [src/app/api/v1/posts.py], there's an inconsistency in how database objects are handled after being fetched with fastcrud.

When a user is fetched using crud_users.get(..., schema_to_select=UserRead), the returned db_user object is a standard Python dict, not an instance of the UserRead Pydantic model as one might expect from the schema_to_select argument.

This leads to AttributeError: 'dict' object has no attribute 'username' when trying to access data using attribute-style access (e.g., db_user.username). The correct method should be dictionary key access (e.g., db_user['username']).

Is it something wrong with my setup or is there actually a bug? I find it hard to belive I'm the first person to discover this, so I wonder if this could be caused by a mismatch in some package versions?

I run this in a container using docker compose up.

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