Skip to content

Awaiting Model.bulk_create on a list of objects returns None and also does not fill the id field of the list items! #1992

@922tech

Description

@922tech

When you await Model.bulk_create on a list of objects it does not add the id fields for the objects.
And this is so lame that I account it as a bug not a feature request!

Sample code:

        accounts = []
        fake = Faker()

        kwargs_dict = dict(
            proxy=fake.random_int(min=1000, max=9999),
            color=fake.random_int(min=0, max=16777215),  # RGB range
            screen_resolution=fake.random_int(min=720, max=2160),
            profile=fake.random_int(min=1, max=1000),
            category=category,
            secret_key=fake.uuid4(),
            username=fake.user_name(),
            password=fake.password(),
            name=fake.name(),
            bio=fake.sentence(nb_words=10),
            email=fake.email(),
            profile_pic_url=fake.image_url(),
            instagram_state=fake.random_element(elements=["active", "inactive", "banned"]),
            app_state=fake.random_element(elements=["idle", "busy"]),
            avatar_changed=fake.random_int(min=0, max=1),
            username_changed=fake.random_int(min=0, max=1),
            initial_posts_deleted=fake.random_int(min=0, max=1),
            has_enough_posts=fake.random_int(min=0, max=1),
            is_used=fake.random_int(min=0, max=1),
            is_active=fake.random_int(min=0, max=1),
            is_public=fake.random_int(min=0, max=1),
            web_session=fake.uuid4(),
            mobile_session=fake.uuid4(),
            log=fake.text(max_nb_chars=200),
            updated_at=datetime.now(),
            next_login=datetime.now(),
        )
        accounts.append(Account(**kwargs_dict))

        t = Account.bulk_create(accounts, 10, True)   # t is None
        # accounts[0].id is also None

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