-
Notifications
You must be signed in to change notification settings - Fork 95
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
Question: using SQL Expression Language table definitions #356
Comments
Hey, I'm not a maintainer but only came across your question today, I know it's a bit of a late response! There isn't any prose section of the docs that addresses this but in the api reference for from marshmallow_sqlalchemy import SQLAlchemyAutoSchema, auto_field
from mymodels import User
class UserSchema(SQLAlchemyAutoSchema):
class Meta:
model = User
# OR
# table = User.__table__
created_at = auto_field(dump_only=True) Notice the commented out part class ExampleSchema(SQLAlchemyAutoSchema):
class Meta:
table = example_table ...I haven't tested it but if that didn't work it would be a bug IMO. Support for generating schemas directly from tables comes from here: marshmallow-sqlalchemy/src/marshmallow_sqlalchemy/convert.py Lines 116 to 141 in 36c403f
|
Better late than never! Thanks for the reply. I'll have to take a look and see if that works. I'll follow up when I get the chance. If it does, it would be nice if it were more prominent in the docs. |
Is this a sane pattern to follow to make use of
SQLAlchemyAutoSchema
with a non-orm (SQL Expression Language) table definition?If there's a better pattern, please let me know. If this is good, I can make a PR to include it in the examples documentation.
The text was updated successfully, but these errors were encountered: