Skip to content

type_annotation_map support #1290

Answered by delicb
delicb asked this question in Q&A
Dec 16, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

If someone faces the same error, flask-sqlalchemy has some additional processing, probably for bind support. Not sure what is exact problem, but I saw some registry manipulation is being done and error message pointed to that, so I have solved the problem by doing the following:

from sqlalchemy.orm import DeclarativeBase, registry
class Base(DeclarativeBase):
    registry = registry(type_annotation_map={str: String(36)})

Note that instead of having type_annotation_map on class level, now registry is defined on class level with type_annotation_map parameter. This seems to work.

Since sqlalchemy documentation mentions first approach and flask-sqlalchemy documentation does not mention this (…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@delicb
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by delicb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants