Skip to content

Enhancement: Skip SQLAlchemy model fields with default values #837

@mtvx

Description

@mtvx

Summary

With something like:

class Study(sqlalchemy.DeclarativeBase):
    mandatory: Mapped[bool] = mapped_column(default=False)

class StudyFactory(SQLAlchemyFactory[Study]):
    pass

study = StudyFactory.build()

# study.mandatory is True or False

Could the SQLAlchemyFactory support skipping fields with a default value (ie. same as declaring them with Ignore()), so that study.mandatory would be always False?

I understand always inserting random values is a strength, but if you're okay with less variety, resorting to default values could be nice. (That's what factory-boy would appear to do by default, AFAIK.)

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions