Skip to content

sparse fields parameter for include causes pydantic error #101

@srepmub

Description

@srepmub

thanks for the awesome project. most of the things I have tried are working - like magic! I did run into a few minor issues though. before diving into the code myself, perhaps you guys already have an idea of what might be the problem there.

for example, the following works fine:

/voorschrijfproduct/51/?include=generiekproduct

this shows 'naam' attributes for both types.

also the following works fine:

/voorschrijfproduct/51/?include=generiekproduct&fields[voorschrijfproduct]=naam

but not the following:

/voorschrijfproduct/51/?include=generiekproduct&fields[voorschrijfproduct]=naam&fields[generiekproduct]=naam

this gives errors (one for each attribute besides 'naam' it seems):

[SQL: SELECT generiekproduct.verval_datum AS generiekproduct_verval_datum 
FROM generiekproduct 
WHERE generiekproduct.id = %s]
[parameters: [{'pk_1': 112615}]]
(Background on this error at: https://sqlalche.me/e/20/xd2s) [type=get_attribute_error, input_value=<model.Generiekproduct object at 0x751c74ac30e0>, input_type=Generiekproduct]
    For further information visit https://errors.pydantic.dev/2.10/v/get_attribute_error

so it looks like pydantic expects the other attributes to still be there, even though only 'naam' comes from the database? (I see in another issue that you changed this recently - perhaps this is caused by not getting everything from the database anymore?)

happy to provide more information, or to try and create a test in your test set for this.

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