Skip to content

Conversation

vkarpov15
Copy link
Collaborator

Fix #15629

Summary

useConnection() hard-codes the model name as the model's collection name, which works in tests but isn't correct in general. Should copy the same collection name from the original model's collection.

Examples

@vkarpov15 vkarpov15 added this to the 8.18.2 milestone Sep 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where useConnection() was incorrectly using the model name as the collection name instead of the actual collection name. The fix ensures that when a model uses a different connection, it preserves the original collection name rather than defaulting to the model name.

  • Updated useConnection() to use the original model's collection name instead of the model name
  • Added test coverage to verify the collection name is preserved correctly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/model.js Fixed useConnection() to use this.collection.collectionName instead of this.modelName
test/model.test.js Added test case with explicit collection name and assertion to verify correct collection name usage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@vkarpov15 vkarpov15 merged commit 219ed6e into master Sep 22, 2025
72 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-15629 branch September 23, 2025 06:59
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.

useConnection() sets collection name to model name
2 participants