Skip to content

Is there a way to disable "deep context" for a factory? #1118

@krispharper

Description

@krispharper

I am working with some SQLAlchemy models that represent database tables that have double underscores in the column names.

class SomeModel(Base):
    column_a: Mapped[int]
    column__b: Mapped[str]

and I have factories to mock these models

class SomeModelFactory(BaseFactory[SomeModel]):
    class Meta(BaseMeta):
        model = SomeModel

    column_a: 1
    column__b: "test"

But when I try to use these factories, I get the error,

 Received deep context for unknown fields

I can't really find anything about this in the documentation, but it seems like there is a sort of convenience mechanic for sub factories called "deep context" that uses double underscores to refer to child fields (I think).

Is there a way to disable that for a given factory so all columns are treated as normal columns? Or some other way to solve this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions