Skip to content
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

Remove support for info={'marshmallow': ...} #567

Merged
merged 1 commit into from Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Expand Up @@ -5,7 +5,9 @@ Changelog
+++++++++++++++++++

* Support marshmallow>=3.10.0.
* Remove ``packaging`` as a requirement.
* Passing `info={"marshmallow": ...}` to SQLAlchemy columns is removed, as it is redundant with
the ``auto_field`` functionality.
* Remove ``packaging`` as a dependency.
* Support Python 3.12.

0.30.0 (2024-01-07)
Expand Down
15 changes: 0 additions & 15 deletions src/marshmallow_sqlalchemy/convert.py
@@ -1,7 +1,6 @@
import functools
import inspect
import uuid
import warnings

import marshmallow as ma
import sqlalchemy as sa
Expand Down Expand Up @@ -284,20 +283,6 @@ def _get_field_kwargs_for_property(self, prop):
self._add_relationship_kwargs(kwargs, prop)
if getattr(prop, "doc", None): # Useful for documentation generation
kwargs["metadata"]["description"] = prop.doc
info = getattr(prop, "info", dict())
overrides = info.get("marshmallow")
if overrides is not None:
warnings.warn(
'Passing `info={"marshmallow": ...}` is deprecated. '
"Use `SQLAlchemySchema` and `auto_field` instead.",
DeprecationWarning,
stacklevel=2,
)
validate = overrides.pop("validate", [])
kwargs["validate"] = self._merge_validators(
kwargs["validate"], validate
) # Ensure we do not override the generated validators.
kwargs.update(overrides) # Override other kwargs.
return kwargs

def _add_column_kwargs(self, kwargs, column):
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Expand Up @@ -107,11 +107,11 @@ class Student(Base):
)

# Test complex column property
subquery = sa.select(sa.func.count(student_course.c.course_id)).where(
student_course.c.student_id == id
course_count = column_property(
sa.select(sa.func.count(student_course.c.course_id))
.where(student_course.c.student_id == id)
.scalar_subquery()
)
subquery = subquery.scalar_subquery()
course_count = column_property(subquery)

@property
def url(self):
Expand Down
18 changes: 0 additions & 18 deletions tests/test_conversion.py
Expand Up @@ -98,24 +98,6 @@ def test_overridden_with_fk(self, models):
graded_paper_fields = fields_for_model(models.GradedPaper, include_fk=False)
assert "id" in graded_paper_fields

def test_info_overrides(self, models):
class TestModel(models.Course):
test = sa.Column(
sa.Text,
nullable=True,
info=dict(
marshmallow=dict(
validate=[validate.Length(max=1000)], required=True
)
),
)

fields_ = fields_for_model(TestModel)
field = fields_["test"]
validator = contains_validator(field, validate.Length)
assert validator.max == 1000
assert field.required

def test_rename_key(self, models):
class RenameConverter(ModelConverter):
def _get_field_name(self, prop):
Expand Down