You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from typing import Any
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.types import JSON
class Base(DeclarativeBase):
type_annotation_map = {dict[str, Any]: JSON}
db = SQLAlchemy(model_class=Base)
Gives the error: sqlalchemy.exc.InvalidRequestError: Declarative base class has both a 'registry' attribute and a type_annotation_map entry. Per-base type_annotation_maps are not supported. Please apply the type_annotation_map to this registry directly.
However, type_annotation_map is supported on the base, but by subclassing the base class (something which seems to be happening inside the plugin), it now detects both the registry created from the base class with type_annotation_map and the type_annotation_map. This doesn't happen without the Flask plugin.
Environment:
Python version: 3.11.6
Flask-SQLAlchemy version: 3.1.1
SQLAlchemy version: 2.0.31
The text was updated successfully, but these errors were encountered:
Theoretically yes - but if that's the official advice it's probably be good to hear that and see this deprecated? If this is still being maintained then it feels like there should be an answer to this question.
Switching to FSL is probably not a hard migration, but it's a chunk of work obviously still. And FSL is a very young lib in comparison.
The plugin breaks the DeclarativeBase, e.g.:
Gives the error:
sqlalchemy.exc.InvalidRequestError: Declarative base class has both a 'registry' attribute and a type_annotation_map entry. Per-base type_annotation_maps are not supported. Please apply the type_annotation_map to this registry directly.
However,
type_annotation_map
is supported on the base, but by subclassing the base class (something which seems to be happening inside the plugin), it now detects both the registry created from the base class withtype_annotation_map
and thetype_annotation_map
. This doesn't happen without the Flask plugin.Environment:
The text was updated successfully, but these errors were encountered: