-
Notifications
You must be signed in to change notification settings - Fork 94
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
RemovedInMarshmallow4Warning: Passing field metadata as a keyword arg is deprecated. Use the explicit metadata=...
argument instead.
#361
Comments
Good catch! Would you like to send a PR @peterschutt ? |
This also happens with the For example: When I use from marshmallow_sqlalchemy import SQLAlchemySchema
class BookSchema(SQLAlchemySchema):
class Meta(SQLAlchemySchema.Meta):
model = BookModel
authors = auto_field(column='name') |
@AbdealiJK What are the columns of |
Here is a fully reproducible example: from marshmallow_sqlalchemy import SQLAlchemySchema, auto_field
from sqlalchemy import Column, ForeignKey, Integer, String, Table, UniqueConstraint
from sqlalchemy.ext.declarative.api import declarative_base
from sqlalchemy.orm import relationship
BaseModel = declarative_base()
book_author_assoc = Table(
'book_author_assoc',
BaseModel.metadata,
Column('id', Integer, primary_key=True, autoincrement=True),
Column('book_id', Integer, ForeignKey('book.id', ondelete='CASCADE'), nullable=False),
Column('author_id', Integer, ForeignKey('author.id'), nullable=False),
UniqueConstraint('book_id', 'author_id'),
)
class AuthorModel(BaseModel):
__tablename__ = 'author'
id = Column(Integer, primary_key=True)
name = Column(String(255), nullable=False, unique=True)
class BookModel(BaseModel):
__tablename__ = 'book'
id = Column(Integer, primary_key=True)
name = Column(String(255), nullable=False, unique=True)
authors = relationship(AuthorModel, secondary=book_author_assoc, lazy='selectin')
class BookSchema(SQLAlchemySchema):
class Meta(SQLAlchemySchema.Meta):
model = BookModel
authors = auto_field(column='name') And you can run it with: |
There's a few more warnings that the test suite throws:
|
@AbdealiJK the correct parameter to marshmallow-sqlalchemy/src/marshmallow_sqlalchemy/schema/sqlalchemy_schema.py Lines 189 to 195 in 6c2edaa
...that's why |
Hi @peterschutt Here are the behaviors:
The
The problem seems to be here:
Where the sake **kwargs is being sent to both RelatedList and Related - So, Related works right. But RelatedList shows this warning.
|
Oh yes, I see.. sorry I didn't give your example as much consideration as it deserved. I've actually been considering how to manage that part of I'm about to send through a PR, let me know if you agree, or not, with the design. |
There is also this warning: marshmallow-sqlalchemy/tests/test_model_schema.py Lines 716 to 736 in 6c2edaa
Which is a result of the nested lecture objects not having an |
Env
marshmallow-sqlalchemy==0.24.1
marshmallow==3.10.0
sqlalchemy==1.3.22
Issue
ModelConverter._add_column_kwargs()
passes a"places"
keyword argument tofields.Float
which isn't part of the fields signature. Until now it would have been silently swallowed into field metadata, however it now generates a warning:It checks for the column type to have a
scale
property:marshmallow-sqlalchemy/src/marshmallow_sqlalchemy/convert.py
Lines 277 to 278 in ca4c3be
Both
Float
andNumeric
/Decimal
column types have thescale
property, yet only theDecimal
field type accepts theplaces
arg.The sqlalchemy
Numeric
type has theasdecimal
flag:Changing the above check to this seems to work well:
...which only passes
places
to the field constructor when sqlalchemy is explicit about using a decimal type.The text was updated successfully, but these errors were encountered: