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

Default value of load_instance changes between ModelSchema and SQLAlchemySchema

Open andrewbrannan opened this issue 5 years ago • 0 comments

I came across this when migrating some schemas this week. The deprecated ModelSchema class has the load_instance attribute set True by default "for backwards compatibility".

https://github.com/marshmallow-code/marshmallow-sqlalchemy/blob/37ded650384756904d8af7af63cbc29c0b5280b7/src/marshmallow_sqlalchemy/schema/model_schema.py#L33

The newer SQLAlchemySchema doesn't have this so it defaults to False.

Our schemas weren't explicitly setting this when using ModelSchema but did rely on it so it took a bit of digging to realise we needed to set it explicitly now that we're using SQLAlchemySchema. I assume that having it it default to False is preferred and the docs show it explicitly being set to True so shouldn't be an issue for new projects. If it's agreed that the default of False is correct I think it's worth adding a note to the docs for anybody else migrating to SQLAlchemySchema, I'm happy to open a PR for that if that makes sense.

andrewbrannan avatar Jun 30 '20 10:06 andrewbrannan