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

joined unique() question #96

Closed
hgalytoby opened this issue Jun 15, 2024 · 3 comments
Closed

joined unique() question #96

hgalytoby opened this issue Jun 15, 2024 · 3 comments

Comments

@hgalytoby
Copy link

hgalytoby commented Jun 15, 2024

Hello! I have been developing from this template since 2022.

At that time I saw that the model was using {"lazy": "selectin"} and I used it myself without any problems.

However, there are times when I need to use joined to improve performance, but when I use joined I have a problem with unique().

I came across #20 and changed selectin to use joined.

I found from https://github.com/jonra1993/fastapi-alembic-sqlmodel-async/blob/main/backend/app/app/crud/base_crud.py#L35 that unique() is not used.

I ran docker-compose-dev.yml and the API works fine.

My model uses sa_relationship_kwargs={"lazy": "joined"}.

But in my context must use response.unique().scalar_one_or_none()!

I would like to know why there is no problem with this project, but I am having problems.

Could it be a version issue? After all, I developed this project with reference to 2022 and the kit is a bit old.

Thanks for any feedback.

@jonra1993
Copy link
Owner

Hello @hgalytoby which version of fastapi, pydantic and sqlmodel are you using?

@hgalytoby
Copy link
Author

hgalytoby commented Jun 22, 2024

fastapi 0.97.0
sql model 0.0.8
pydantic 1.10.15

This is just a minor question, I'm just curious.

I know the kit version is very old, but if it's the kit version I have no doubt.

After all, I developed this project with reference to 2022.

@hgalytoby
Copy link
Author

hgalytoby commented Jul 9, 2024

It's been a long time since I've used SQL and my own project is very old, so I'm asking out of curiosity and not trying to learn with the latest version.

I think if I implement the latest version, I should be able to solve the problem.

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

No branches or pull requests

2 participants