Skip to content

Why does adding a registry break tables being connected to the same MetaData instance? #957

Discussion options

You must be logged in to vote

OK, so after being stuck for two days, of course I found a solution ten minutes after having posted a question.
This seems to work, but it's quite counterintuitive, and would probably deserve a mention in the docs.

from sqlmodel import SQLModel, Field
from sqlalchemy.orm import registry


registry_one = registry()


class BaseOne(SQLModel, registry=registry_one):
    ...


class ModelOneA(BaseOne, table=True):
    id: int | None = Field(primary_key=True)
    description: str


class ModelOneB(BaseOne, table=True):
    id: int | None = Field(primary_key=True)
    description: str


registry_two = registry()


class BaseTwo(SQLModel, registry=registry_two):
    ...


class ModelTwoA(BaseTwo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mikulas-mrva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
1 participant