Skip to content

Bug 47910.count query text block#47911

Open
Blackbaud-JasonBodnar wants to merge 5 commits intoAzure:mainfrom
Blackbaud-JasonBodnar:bug_47910.count_query_text_block
Open

Bug 47910.count query text block#47911
Blackbaud-JasonBodnar wants to merge 5 commits intoAzure:mainfrom
Blackbaud-JasonBodnar:bug_47910.count_query_text_block

Conversation

@Blackbaud-JasonBodnar
Copy link

Description

Fix #47910 by adding Pattern.DOTALL to StringBasedCosmosQuery.COUNT_QUERY_PATTERN.

According to the JavaDoc:

In dotall mode, the expression . matches any character, including a line terminator. By default this expression does not match line terminators.

All SDK Contribution checklist:

  • [ X ] The pull request does not introduce [breaking changes]
  • [ X ] CHANGELOG is updated for new features, bug fixes or other significant changes.
  • [ X ] I have read the contribution guidelines.

General Guidelines and Best Practices

  • [ X ] Title of the pull request is clear and informative.
  • [ X ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • [ X ] Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings February 5, 2026 17:57
@github-actions github-actions bot added azure-spring All azure-spring related issues Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Feb 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Thank you for your contribution @Blackbaud-JasonBodnar! We will review the pull request and get back to you soon.

Copy link
Contributor

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 a bug where count queries defined using Java text blocks in @Query annotations caused a ClassCastException. The root cause was that the COUNT_QUERY_PATTERN regex didn't include the Pattern.DOTALL flag, which prevents the . metacharacter from matching newline characters present in text blocks.

Changes:

  • Added Pattern.DOTALL flag to COUNT_QUERY_PATTERN in StringBasedCosmosQuery.java
  • Added unit test to verify count queries with text blocks are correctly recognized
  • Updated CHANGELOG.md to document the bug fix

Reviewed changes

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

File Description
sdk/spring/azure-spring-data-cosmos/src/main/java/com/azure/spring/data/cosmos/repository/support/StringBasedCosmosQuery.java Adds Pattern.DOTALL flag to COUNT_QUERY_PATTERN regex to handle newlines in text blocks
sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/repository/support/StringBasedCosmosQueryUnitTest.java Adds unit test verifying count queries with Java text blocks work correctly
sdk/spring/azure-spring-data-cosmos/CHANGELOG.md Documents the bug fix for issue #47910

@rujche
Copy link
Member

rujche commented Feb 6, 2026

Hi, @kushagraThapar , @trande4884 , could you please help to review this PR?

@rujche rujche moved this from Todo to In Progress in Spring Cloud Azure Feb 6, 2026
Copy link
Contributor

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

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

@rujche rujche modified the milestones: 2026-02, 2026-03 Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Spring - Cosmos azure-spring All azure-spring related issues azure-spring-cosmos Spring cosmos related issues. Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[BUG] Spring count @Query with java text block generates an error

4 participants