Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix efficiency of QuerySet.bulk_create() #26

Merged
merged 1 commit into from
May 21, 2024

Conversation

timgraham
Copy link
Collaborator

No description provided.

inserted_id = collection.insert_one(doc, **options).inserted_id
return [inserted_id] if returning_fields else []
inserted_ids = collection.insert_many(docs, **options).inserted_ids
return [inserted_ids] if returning_fields else []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return [inserted_ids] if returning_fields else []
return inserted_ids if returning_fields else []

this can just be inserted_ids now since inserted_ids is already a list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute_sql() must return a nested list, and since it no longer accumulates values in keys, this is correct.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, got it!

@@ -18,3 +24,89 @@ def check_django_compatability():
f"You must use the latest version of django-mongodb {A}.{B}.x "
f"with Django {A}.{B}.y (found django-mongodb {__version__})."
)


class CollectionDebugWrapper:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this class part of the PR? It looks to be related to getting debug information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you saw, the first commit is #25. It's a dependency of this PR but I'll merge the other PR first so it'll no longer appear here.

Copy link
Collaborator

@Jibola Jibola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarifications. LGTM

@timgraham timgraham merged commit d2fff08 into mongodb-labs:main May 21, 2024
3 checks passed
@timgraham timgraham deleted the bulkcreate branch May 21, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants