Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AdminModelConverter.get_converter()looks up a converter using the column type's own class hierarchy. A column with a customTypeDecorator(the way SQLAlchemy recommends extending built-in types) therefore finds no converter, and the field is silently left out of the create/edit form:This adds a fallback to the SQLAlchemy converter: when nothing is registered for the decorator itself, it uses the converter for the wrapped
impltype, following nested decorators. Converters registered for a decorator class (e.g. thesqlalchemy_utilstypes likeEmailTypeorArrowType) are still found first, so their behaviour doesn't change. Converters that read attributes such ascolumn.type.lengthkeep working becauseTypeDecoratorproxies attribute access toimpl.To reuse the lookup for a type rather than a column, the body of
ModelConverterBase.get_converter()moves into a_get_type_converter()helper;get_converter()keeps its signature and behaviour.fixes #1857
Tests:
test_form_type_decoratorcovers a decoratedString(20)(gets aStringFieldwith aLength(max=20)validator), a decoratedDateTimeand a nested decorator. It fails onmasterwith'ModelForm' object has no attribute 'name'. The sqla and peewee tests pass. The only other failures need a MongoDB server, plustest_export_tablib, which fails onmasteras well. ruff and mypy report nothing new. Changelog entry added.