Skip to content
Discussion options

You must be logged in to vote

it looks like the class init for DeclarativeBase is hardcoded to use the dictionary of the immediate class:

if "type_annotation_map" in cls.__dict__:

so to workaround you'd have to populate this

from __future__ import annotations

from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column
from sqlalchemy.types import BigInteger

type BigInt = int

class _TypeDeclarations:
    type_annotation_map = {
        BigInt: BigInteger
    }

    def __init_subclass__(cls) -> None:
        # make sure this is set
        cls.t…

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@zzzeek
Comment options

Answer selected by funkyfuture
@CaselIT
Comment options

@zzzeek
Comment options

@CaselIT
Comment options

@CaselIT
Comment options

Comment options

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

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants