BigInteger column is not created as INTEGER with DeclerativeBase and Metadata.create_all #13197
-
|
i'm assuming that i'm missing something in the documentation, so i'm keeping my description brief for now. i have an ORM model that includes a BigInteger property/column, declared and created as table like this: from sqlalchemy.orm import mapped_column, DeclarativeBase, Mapped
from sqlalchemy.types import BigInteger
type BigInt = int
class _TypeDeclarations:
type_annotation_map = {
BigInt: BigInteger
}
class Base(DeclarativeBase, _TypeDeclarations): pass
class MyModel(Base):
__tablename__ = "my_table"
id: Mapped[int] = mapped_column(primary_key=True)
my_bigint: Mappped[BigInt] = mapped_column()
#
MyModel.metadata.create_all(engine)however, the i tried this with two different drivers to connect to MariaDB and using i appreciate any hint in this regard. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
|
hi - it looks like your class ordering is not having your type_annotation_map taking effect since DeclarativeBase includes a blank one in its dictionary fix as follows |
Beta Was this translation helpful? Give feedback.
-
|
thanks, i already had this suspicion, but the ordering has no effect, this is the same for both variants of base class order: >>> MyModel.type_annnotation_map
{BigInt: <class 'sqlalchemy.sql.sqltypes.BigInteger'>}when i omit |
Beta Was this translation helpful? Give feedback.
-
|
thank you. that explicit assignment works. i think it'd be desirable that the setup function that @CaselIT points at, looks through the class' in my context i'm choosing this mixin-approach b/c i have multiple base classes for models / databases to talk to. |
Beta Was this translation helpful? Give feedback.
-
|
Yes
…On Tue, Mar 24, 2026, at 12:00 PM, Federico Caselli wrote:
Do we want to create an issue?
—
Reply to this email directly, view it on GitHub <#13197?email_source=notifications&email_token=AAA7JXZA4WBUWOPDEVV2PJL4SKWJXA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNRSHE2TONRWUZZGKYLTN5XKOY3PNVWWK3TUUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#discussioncomment-16295766>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAA7JX7QW4LKC2XDCNMNGOL4SKWJXAVCNFSM6AAAAACW5NFCJOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMMRZGU3TMNQ>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
it looks like the class init for
DeclarativeBaseis hardcoded to use the dictionary of the immediate class:sqlalchemy/lib/sqlalchemy/orm/decl_api.py
Line 537 in 1aa259f
so to workaround you'd have to populate this