Skip to content

Model factory with relation and 0 count still creates relationship #1128

@m-i-c-h-a-l

Description

@m-i-c-h-a-l

Package version

21.6.1

Describe the bug

I have a model factory:
export const MyFactory = factory
.define(MyModel, async () => {
return { };
})
.relation('users', () => UserFactory)
.build();

I'm using factories in integration tests and these tests have scenarios (test datasets) with dynamic user count including 0. I realized using .with('users', 0) still creates 1 user.

Expected: No user is created.

Reproduction repo

No response

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