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

[cosmos] continuation Token is not returned with an ORDER BY query node JS SDK #32367

Open
2 tasks
adeelnaqvisystems opened this issue Dec 26, 2024 · 2 comments
Open
2 tasks
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@adeelnaqvisystems
Copy link

adeelnaqvisystems commented Dec 26, 2024

  • Package Name: azure/cosmos

  • Package Version: 4.2.0

  • Operating system: window

  • nodejs: v 20.15.1

    • framework: Nest JS
  • typescript

    • version: ^5.1.3

Describe the bug
Continuation tokens are undefined for ORDER BY queries. The query SELECT * FROM a returns a continuation token as expected, however SELECT * FROM a ORDER BY a._ts ASC send undefended

To Reproduce
The following node js script connects to a container and performs the simplest query with ORDER BY, if you've got more than 10 items, it'll return 10 items, but no continuation token. Remove the ORDER BY, and it works fine:

let query =SELECT * FROM students u WHERE u.type = @entityType`;

if (studentsIds && studentsIds.length > 0) {
  query += ` AND u.studentId IN (${studentIds.map((_, i) => `@studentId${i}`).join(', ')})`;
}

if (sorted) {
  query += ` ORDER BY u.studentId ASC`;
}

const querySpec = {
  query,
  parameters: [
    { name: '@entityType', value: 'student' },
    ...studentIds.map((id, i) => ({
      name: `@studentId${i}`,
      value: id
    }))
  ]
};

const options: any = {
  maxItemCount: limit
};

if (continuationToken) {
  options.continuationToken = continuationToken;
}

const result = await this.container.items.query<student>(querySpec, options).fetchNext();

return {
  items: result.resources,
  continuationToken: result.continuationToken
};

// its in my db container where studentId is partition key
@CosmosPartitionKey('studentId')
export class StudnetsContainer {
studentId: string;
}

`

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. labels Dec 26, 2024
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sajeetharan @simorenoh.

@adeelnaqvisystems
Copy link
Author

Waiting for the response @sajeetharan @simorenoh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

1 participant