Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] project method for find query doesn't work #1016

Open
hagd0520 opened this issue Sep 5, 2024 · 2 comments
Open

[BUG] project method for find query doesn't work #1016

hagd0520 opened this issue Sep 5, 2024 · 2 comments

Comments

@hagd0520
Copy link

hagd0520 commented Sep 5, 2024

Describe the bug
project method for find query doesn't work. It only return the whole Document instead and is same with projection_model parameter in find method.

To Reproduce
code below returns whole Document.

class UpdatedAtResponse(BaseModel):
    id: Annotated[PydanticObjectId, Field(validation_alias=AliasChoices('id', "_id"))]
    updatedAt: datetime

await Article.find().project(UpdatedAtResponse).to_list()

It works only if i get this through with Settings, projection config like below code as written in beanie official document

class ProductView(BaseModel):
    name: str
    category: str

    class Settings:
        projection = {"name": 1, "category": "$category.name"}

Expected behavior
I hope project method works properly.

Copy link
Contributor

github-actions bot commented Oct 6, 2024

This issue is stale because it has been open 30 days with no activity.

@github-actions github-actions bot added the Stale label Oct 6, 2024
@staticxterm
Copy link

Hi, thank you for the report.
I'm unable to reproduce this. Please provided a minimum reproducible example that is fully runnable.
ProductView is not a proper View class with Beanie required fields: source, pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants