Closed slaarti closed 1 month ago
Hey, @slaarti, thanks for the issue! I'll fix it. I believe I basically took stuff from the written tests for the docs, so it should work, but version changes and human errors mess everything up.
Okay, well, I went through all of the docs/
, fastcrud/
, and tests/
directories, and compiled all of the tables and schemas that were referenced (sometimes in multiple places, but I just noted where I first saw them) and/or defined. Sometimes there are not-quite-duplicates, like UserCreateSchema
and CreateUserSchema
, which I noted down separately but should probably be unified somehow.
Item
- table - defined in docs/index.md
:tada:ItemSchema
- schema - defined in docs/index.md
:tada:ItemCreateSchema
- schema - defined in docs/index.md
:tada:ItemUpdateSchema
- schema - defined in docs/index.md
:tada:Order
- table - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:OrderModel
- table - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:OrderSchema
- schema - ref'd in docs/usage/crud.md
- Undefined :exclamation:OrderCreateSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:OrderReadSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:CreateOrderSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:UpdateOrderSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:Customer
- table - ref'd in docs/usage/crud.md
- Undefined :exclamation:CustomerSchema
- schema - ref'd in docs/usage/crud.md
- Undefined :exclamation:Project
- table - defined in tests/*/conftest.py
:tada:ProjectSchema
- schema - ref'd in docs/advanced/crud.md
- Undefined :exclamation:Participant
- table - defined in tests/*/conftest.py
:tada:User
- table - incompletely defined in docs/advanced/joins.md
:interrobang:UserModel
- table - ref'd in docs/advanced/crud.md
- Undefined :exclamation:UserSchema
- schema - ref'd in docs/advanced/crud.md
- Undefined :exclamation:UserCreateSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:UserUpdateSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:UserReadSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:CreateUserSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:UpdateUserSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:Tier
- table - defined in docs/advanced/joins.md
:interrobang:TierModel
- table - defined in tests/*/conftest.py
:tada:TierSchema
- schema - ref'd in docs/advanced/crud.md
- Undefined :exclamation:Tier
and TierModel
are nearly identical, except that TierModel
has a field relating it to the ModelTest
table; are they supposed to be the same? There's also a TierSchemaTest
in the conftest.py
files; should TierSchema
be renamed to this?
Department
- table - ref'd in docs/advanced/crud.md
- Undefined :exclamation:DepartmentSchema
- schema - ref'd in docs/advanced/crud.md
- Undefined :exclamation:Task
- table - ref'd in docs/advanced/crud.md
- Undefined :exclamation:TaskModel
- table - ref'd in docs/advanced/crud.md
- Undefined :exclamation:TaskSchema
- schema - ref'd in docs/advanced/crud.md
- Undefined :exclamation:TaskCreateSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:CreateTaskSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:UpdateTaskSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:MyModel
- table - defined in docs/advanced/endpoint.md
:tada:CreateMyModel
- schema - ref'd in docs/advanced/endpoint.md
- Undefined :exclamation:UpdateMyModel
- schema - ref'd in docs/advanced/endpoint.md
- Undefined :exclamation:CreateMyModelSchema
- schema - ref'd in docs/advanced/endpoint.md
- Undefined :exclamation:UpdateMyModelSchema
- schema - ref'd in docs/advanced/endpoint.md
- Undefined :exclamation:DeleteMyModelSchema
- schema - ref'd in docs/advanced/endpoint.md
- Undefined :exclamation:Role
- table - ref'd in docs/advanced/joins.md
- Undefined :exclamation:Product
- table - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:ProductModel
- table - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:ProductCreateSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:ProductReadSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:CreateProductSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:UpdateProductSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:DeleteProductSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:Comment
- table - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:CommentCreateSchema
- schema - ref'd in fastcrud/crud/fast_crud.py
- Undefined :exclamation:ModelTest
- table - defined in tests/*/conftest.py
:tada:BookingModel
- table - defined in tests/*/conftest.py
:tada:BookingSchema
- schema - defined in tests/*/conftest.py
:tada:CustomerModel
- table - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:CreateCustomerSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:UpdateCustomerSchema
- schema - ref'd in fastcrud/endpoint/crud_router.py
- Undefined :exclamation:OtherModel
- table - ref'd in fastcrud/endpoint/endpoint_creator.py
- Undefined :exclamation:CreateOtherModel
- schema - ref'd in fastcrud/endpoint/endpoint_creator.py
- Undefined :exclamation:UpdateOtherModel
- schema - ref'd in fastcrud/endpoint/endpoint_creator.py
- Undefined :exclamation:That is really great work, thank you so much! Do you want to also fix stuff and make a pr?
Uhhh, that depends on the specific stuff. Like, if it's "put together class defs for the models/schemas that currently lack them based on what the docs/code use them for -- IMO ideally in the process cleaning up stuff like there being both (as an example) ProductCreateSchema
and CreateProductSchema
-- and putting them somewhere that can be referenced" ? Sure, I can at least take a crack at that.
However, none of this really resolves the problem that sparked this issue, which is that all of the examples in the FastCRUD
class docstring rely on invoking the class in ways that don't make sense given the actual code, which is something I have no idea what to do about. You're probably going to have to handle that one yourself, since I assume you had some kind of intention/plan with that.
Yeah, sure, I can fix the docstring examples. I can also fix the docs, no problem, just wondering if you'd like to do it.
I'm down to split the work: I can put together the example models/schemas and clean up the docs accordingly, while you fix the docstrings? If that works for you, I can create a separate issue that can be assigned to me for my part, while this one remains for yours.
Sounds good to me! Thanks
>>> user_crud = FastCRUD(User, UserCreateSchema, UserUpdateSchema) >>> user_crud.is_deleted_column <class '__main__.UserCreateSchema'> >>> user_crud.deleted_at_column <class '__main__.UserUpdateSchema'>
The issue here is it should be something like this:
CRUDUser = FastCRUD[User, UserCreateInternal, UserUpdate, UserUpdateInternal, UserDelete]
crud_users = CRUDUser(User)
And it would work. This is useful for typing, but indeed it's wrong in the way I wrote it. I'm fixing the docstring stuff
Aha, that does make a lot more sense, yes. And I see your commits with the fix. Thank you!
Describe the bug or question
According to the documentation, the
FastCRUD
class takes optional create, update, and delete schemas as arguments, but this doesn't make sense according to the calling signature forFastCRUD.__init__()
and indeed it doesn't seem to work in practice.(As a secondary but related matter, the documentation references a bunch of example model/schema classes that are never fully defined anywhere, including the code and tests, which made figuring out how to articulate this fairly tricky. If what the docs say is supposed to work, it's something that probably needs some actual tests written for to confirm.)
To Reproduce
I had to do a little fudging using the
Item
model/schema classes to get a set that'd work for theUser
model referenced in the docs, but it seems to me like this:should work for this (Example 6 from the page listed above, in turn taken from the
FastCRUD
class doc string), and yet:For that matter, Example 1 seems like it works, but the case of it "working" is actually a typing violation: