-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat: ✨ add multiple primary keys support #31
Conversation
Hey, @dubusster, thanks for another improvement! |
Thanks @igorbenav ! |
02a0bd6
to
d758810
Compare
6051ea6
to
129116f
Compare
129116f
to
eef81d0
Compare
Hey, @dubusster, sorry for the long delay here! I'm having some doubts with Forge, since it's pretty much unmaintained since 2018, do you think it's the best approach? To be honest, I experimented with it (basically got to something similar to forge) and it seems like in python this always looks bad. My main concern is with Forge being kind of abandoned. |
Hey @igorbenav ! Indeed, I used forge as the approach since it was already written but it might be smarter to have some piece of code doing the basics and not using this full unmaintained library. I found out some other approach with basic python here, I'll try to fix something in the following days. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great pr, @dubusster, thanks! Just a few minor things and I'll merge it.
65cbfa3
to
e4ea55d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it's my first time doing a review, I don't know if I had to make commits first or "resolving"...
Anyway, I added your suggestions : some docstring for the decorator and a dedicated function to be used during dict comprehension !
Nice one, @dubusster, I'll update the docs before the next release! |
Pull Request Template for FastCRUD
Description
This PR aims to provide multiple primary key handling with the basic crud and the endpoint creator.
This way, for a model such as :
the endpoint creator should gives a path like
/multi_pk/get/{id}/{uuid}
for the different endpoints (get, update and delete) that need primary keys to interact with the database. The order of path parameter is given by the column order.Changes
There is some monkey patching of TypeDecorator to also cover custom types.
Although it works, this piece of code seems a bit hacky and might need improvement from SQLModel or even better sqlalchemy.
Tests
Add multiple primary keys tests on create, get and delete crud/endpoints for both sqlmodel and sqlalchemy.
Checklist
Additional Notes
This PR also allows to not be restricted to the
id
name for primary key 😄