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

FIx force_auto_coercion on composite fields #768

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

atugushev
Copy link

TBD

force_auto_coercion()

@dataclass
class Cursor:
    id: int

class Base:
    id: Mapped[int] = mapped_column(sa.Integer())

class SampleModel(Base):
    cursor = composite(Cursor, "id")

raises

.venv/lib/python3.11/site-packages/sqlalchemy/orm/mapper.py:2388: in _check_configure
    _configure_registries({self.registry}, cascade=True)
.venv/lib/python3.11/site-packages/sqlalchemy/orm/mapper.py:4203: in _configure_registries
    _do_configure_registries(registries, cascade)
.venv/lib/python3.11/site-packages/sqlalchemy/orm/mapper.py:4246: in _do_configure_registries
    mapper.dispatch.mapper_configured(mapper, mapper.class_)
.venv/lib/python3.11/site-packages/sqlalchemy/event/attr.py:378: in __call__
    fn(*args, **kw)
.venv/lib/python3.11/site-packages/sqlalchemy/orm/events.py:891: in wrap
    fn(*arg, **kw)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

mapper = <Mapper at 0x126628c50; SimpleModel>, class_ = <class 'tests.integration.infinite_pagination_test.SimpleModel'>

    def coercion_listener(mapper, class_):
        """
        Auto assigns coercing listener for all class properties which are of coerce
        capable type.
        """
        for prop in mapper.iterate_properties:
            try:
>               listener = prop.columns[0].type.coercion_listener
E               IndexError: list index out of range

.venv/lib/python3.11/site-packages/sqlalchemy_utils/listeners.py:13: IndexError
                                                                                  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant