Skip to content

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