I have an application that manages separate databases, Postgres and SQLite. My Postgres models use CompositeType which causes a before_create DDL event to be registered with a global registered_composite for this column. When SQLAlchemy is creating the SQLite database, it attempts to run this composite but fails as SQLite dialect does not support them.
Fundamentally, this seems to be because SQLALchemy-Utils treats registration as global, not per connection. This seems to be agreed by an ominous TODO...
|
# TODO: Make the registration work on connection level instead of global level |
Git blame shows this hasn't been touched since it was added 10 years ago. I couldn't find a corresponding issue for this TODO.
Can this be fixed? Or, is there a better way to handle Postgres composite types outside of SQLAlchemy-Utils?
I have an application that manages separate databases, Postgres and SQLite. My Postgres models use
CompositeTypewhich causes abefore_createDDL event to be registered with a globalregistered_compositefor this column. When SQLAlchemy is creating the SQLite database, it attempts to run this composite but fails as SQLite dialect does not support them.Fundamentally, this seems to be because SQLALchemy-Utils treats registration as global, not per connection. This seems to be agreed by an ominous TODO...
sqlalchemy-utils/sqlalchemy_utils/types/pg_composite.py
Line 158 in e2cbc08
Git blame shows this hasn't been touched since it was added 10 years ago. I couldn't find a corresponding issue for this TODO.
Can this be fixed? Or, is there a better way to handle Postgres composite types outside of SQLAlchemy-Utils?