Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
expected behaviorthat's how it's meant to work. consider the "documentation" label in additionthird party integration issuesissues to do with other libraries and frameworks
Description
Describe the bug
My issue is similar to #9458
except with DescriptorProperty
I have some versioned tables in my project using SQLAlchemy-Continuum (v1.4.0) and for migrations I use Alembic (v1.12.0)
and I'm upgrading SQLAlchemy from v1.4.49 to v2.0.21 (no deprecation warnings).
I have some synonyms in my classes which seem to be the culprit here since DescriptorProperty doesn't have a dispatch
Optional link from https://docs.sqlalchemy.org which documents the behavior that is expected
No response
SQLAlchemy Version in Use
2.0.21
DBAPI (i.e. the database driver)
psycopg2
Database Vendor and Major Version
PostgreSQL 14
Python Version
3.11.5
Operating system
Ubuntu/Windows
To Reproduce
from datetime import datetime
from sqlalchemy import String, DateTime, Integer
from sqlalchemy.orm import (
DeclarativeBase,
Mapped,
mapped_column,
configure_mappers,
declared_attr,
synonym,
)
from sqlalchemy_continuum import make_versioned
make_versioned(user_cls=None)
class Base(DeclarativeBase):
pass
class TableBase:
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
create_time: Mapped[datetime] = mapped_column(DateTime(timezone=True))
@declared_attr
def createTime(cls):
return synonym("create_time")
class A(Base, TableBase):
__versioned__ = {}
__tablename__ = "table_a"
property_a: Mapped[str] = mapped_column(String)
propA = synonym(property_a)
configure_mappers()Error
Traceback (most recent call last):
File "~/example.py", line 37, in <module>
configure_mappers()
File "~/venv/lib/python3.11/site-packages/sqlalchemy/orm/mapper.py", line 4168, in configure_mappers
_configure_registries(_all_registries(), cascade=True)
File "~/venv/lib/python3.11/site-packages/sqlalchemy/orm/mapper.py", line 4202, in _configure_registries
Mapper.dispatch._for_class(Mapper).after_configured() # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/venv/lib/python3.11/site-packages/sqlalchemy/event/attr.py", line 378, in __call__
fn(*args, **kw)
File "~/venv/lib/python3.11/site-packages/sqlalchemy/orm/events.py", line 887, in wrap
fn(*arg, **kw)
File "~/venv/lib/python3.11/site-packages/sqlalchemy_continuum/builder.py", line 23, in check_reentry
handler(*args, **kwargs)
File "~/venv/lib/python3.11/site-packages/sqlalchemy_continuum/builder.py", line 191, in configure_versioned_classes
self.enable_active_history(pending_classes_copies)
File "~/venv/lib/python3.11/site-packages/sqlalchemy_continuum/builder.py", line 205, in enable_active_history
impl.active_history = True
^^^^^^^^^^^^^^^^^^^
File "~/venv/lib/python3.11/site-packages/sqlalchemy/orm/attributes.py", line 942, in _set_active_history
self.dispatch._active_history = value
^^^^^^^^^^^^^
AttributeError: '_ProxyImpl' object has no attribute 'dispatch'
Additional context
No response
Metadata
Metadata
Assignees
Labels
expected behaviorthat's how it's meant to work. consider the "documentation" label in additionthird party integration issuesissues to do with other libraries and frameworks
Activity
zzzeek commentedon Oct 6, 2023
hi, please report this to sqlalchemy_continuum, this code here:
https://github.com/kvesteri/sqlalchemy-continuum/blob/ccd87070baee40546f3289135e655ecf79b48cf8/sqlalchemy_continuum/builder.py#L194-L205
should also exclude synonyms. Additionally they should review the SQLAlchemy 2.0 version of versioned history which does not require use of the private ".impl" attribute