Skip to content

Conversation

manekinekko
Copy link
Collaborator

@manekinekko manekinekko commented Jun 10, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #1165

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

paths: [`/${partitionKey}`],
};
}
else if (typeof partitionKey === 'object') {

Choose a reason for hiding this comment

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

I think the partition key might be an array, which will still resolve to object and in this case will work just fine. Looks good to me :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand the confusion here, but partitionKey here represents actually entityDescriptor.partitionKey object, not the partition keys values (paths).

@manekinekko manekinekko requested a review from Copilot July 3, 2025 07:41
Copy link

@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 enhances partition key handling, broadens dependency compatibility, and cleans up related code.

  • Adds runtime checks in provider to distinguish string vs. object partitionKey definitions.
  • Updates package.json to support NestJS v10 and v11 and loosen Azurite version.
  • Removes a no-op test hook and tweaks core module destructuring to adjust forwarded SDK options.

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sample/cosmos-db/src/event/event.entity.ts Minor formatting (trailing commas/semicolons) to align syntax.
package.json Expanded version ranges for @nestjs/* and azurite dependencies.
lib/cosmos-db/cosmos-db.providers.ts Added type guards and error handling for partitionKey definitions.
lib/cosmos-db/cosmos-db.decorators.spec.ts Removed commented mock and replaced with an empty beforeEach hook.
lib/cosmos-db/cosmos-db-core.module.ts Excluded connectionName from destructuring to change SDK parameters.
Files not reviewed (1)
  • sample/cosmos-db/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

lib/cosmos-db/cosmos-db.decorators.spec.ts:5

  • [nitpick] This empty beforeEach block is redundant and can be removed to streamline the tests.
  beforeEach(() => {});

provide: cosmosConnectionName,
useFactory: async (cosmosModuleOptions: AzureCosmosDbOptions): Promise<any> => {
const { dbName, retryAttempts, retryDelay, connectionName, ...cosmosOptions } = cosmosModuleOptions;
const { dbName, retryAttempts, retryDelay, ...cosmosOptions } = cosmosModuleOptions;
Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

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

connectionName is no longer excluded and will be spread into cosmosOptions, potentially passing an unsupported option to the Azure SDK. Re-introduce connectionName in the destructuring exclusion or explicitly delete it from cosmosOptions.

Suggested change
const { dbName, retryAttempts, retryDelay, ...cosmosOptions } = cosmosModuleOptions;
const { dbName, retryAttempts, retryDelay, connectionName, ...cosmosOptions } = cosmosModuleOptions;

Copilot uses AI. Check for mistakes.

@peterkracik
Copy link

This seems to solve the issue for us 👍

Copy link

@peterkracik peterkracik 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 working on this fix!

};
}
else if (typeof partitionKey === 'object') {
containerOptions.partitionKey = partitionKey;

Choose a reason for hiding this comment

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

I found one issue, it throws an error if the property path is an empty array

@CosmosPartitionKey({
  paths: [],
  version: PartitionKeyDefinitionVersion.V2,
  kind: PartitionKeyKind.MultiHash,
})

@murbanowicz
Copy link

Hey!
Maybe would be possible to address #1342 with this change? Or maybe it will fix it already?

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.

5 participants