Skip to content

Cross-DB Outbox Model Compatibility

Latest

Choose a tag to compare

@vadikko2 vadikko2 released this 05 Mar 15:10
· 1 commit to master since this release
0dfed4f

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 the LargeBinary column. The value is always provided explicitly in the add() method.
  • func.UUID_TO_BIN — the MySQL-specific function has been replaced with event.event_id.bytes (pure Python), ensuring compatibility with both databases.
  • BinaryUUID.process_bind_param — string UUIDs are now normalized to uuid.UUID before 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 sqlalchemy extra to pyproject.toml (sqlalchemy[asyncio]==2.0.*) for explicit installation via pip install python-cqrs[sqlalchemy].
  • Package version: 4.10.04.10.1.