Cross-DB Outbox Model Compatibility
BinaryUUID TypeDecorator — a new type for the event_id column that transparently stores UUIDs as native UUID in PostgreSQL and as BINARY(16) in MySQL. This replaces the previous sqlalchemy.Uuid, which did not work correctly with MySQL.
OutboxModel Migration to SQLAlchemy 2.x
All OutboxModel columns have been migrated from the legacy sqlalchemy.Column(...) style to the declarative Mapped[T] = mapped_column(...) (SQLAlchemy 2.x). The payload type has been changed from the MySQL-specific mysql.BLOB to the portable sqlalchemy.LargeBinary.
Fixes
payload default={}— removed an incorrect mutable default (dict instead of bytes) on theLargeBinarycolumn. The value is always provided explicitly in theadd()method.func.UUID_TO_BIN— the MySQL-specific function has been replaced withevent.event_id.bytes(pure Python), ensuring compatibility with both databases.BinaryUUID.process_bind_param— string UUIDs are now normalized touuid.UUIDbefore the dialect check, preventing a raw string from being passed to asyncpg (PostgreSQL).
Guarded Imports for SQLAlchemy Modules
In src/cqrs/outbox/sqlalchemy.py and src/cqrs/saga/storage/sqlalchemy.py, direct SQLAlchemy imports have been wrapped in try/except ImportError with a clear message and installation instructions (pip install python-cqrs[sqlalchemy]). Added from None for a clean traceback.
Dependencies
- Added an optional
sqlalchemyextra topyproject.toml(sqlalchemy[asyncio]==2.0.*) for explicit installation viapip install python-cqrs[sqlalchemy]. - Package version:
4.10.0→4.10.1.