marshmallow-sqlalchemy icon indicating copy to clipboard operation
marshmallow-sqlalchemy copied to clipboard

Set schema partial attribute in Meta class

Open alexphi314 opened this issue 3 years ago • 2 comments

Is it possible to set the schema.partial attribute in the Meta class for SQLAlchemyAutoSchemas?

I would like to use SQLALchemyAutoSchemas with frameworks that don't allow me to set partial=True in the load_instance call (because it is done automatically) -- that setting is inherited from the schema definition. It seems like it might not be possible to set partial=True for a SQLAlchemyAutoSchema directly.

If this is not possible, could the Meta class be improved to support this?

alexphi314 avatar Aug 03 '22 00:08 alexphi314

Any update on this?

Due to another limitation of ma-sqla (multiple variations on a schemas will trigger a naming collision warning), it is not really practical to use MySchema and MySchema(partial=True) in the same REST API (having both is a typical pattern to support CRUD endpoints).

But as mentioned above, defining a class MySchemaPartial(MySchema) that sets partial = True in Meta does not seem to work…

Edit: Possibly related (and dependent) on: https://github.com/marshmallow-code/marshmallow/issues/2103

zedrdave avatar Aug 14 '23 16:08 zedrdave

Yes. Let's tackle this in https://github.com/marshmallow-code/marshmallow/issues/2103 first.

lafrech avatar Sep 10 '23 19:09 lafrech