Fix/40139 calculate total row count#40691
Open
odegroot1234 wants to merge 4 commits intodbeaver:develfrom
Open
Fix/40139 calculate total row count#40691odegroot1234 wants to merge 4 commits intodbeaver:develfrom
odegroot1234 wants to merge 4 commits intodbeaver:develfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The "Calculate total row count" feature in DBeaver versions 25.3.3 and 26.0.1 throws an exception when executing MSSQL queries. According to issue #40139, this is a regression introduced in version 25.3.3 which previously functioned correctly in 25.3.2.
Cause
This failure can be attributed to the wrapSourceQuery() method in SQLQueryTransformerCount.java. In the method, SQLSemanticProcessor.parseQuery() was called and stored as a Statement object without a SQL dialect parameter as context. As a result, the parser could not handle the MSSQL syntax used in the query, preventing the statement from being recognized as a valid PlainSelect instance and throwing an exception.
Bug Fix
Extracted dataSource.getSQLDialect() as the named variable sqlDialect and passed it as a context parameter to SQLSemanticProcessor.parseQuery(). Verified the fix against the original bug report query from #40139 as well as other queries on MSSQL 2022 via a Docker container.
Additional Observation
After selecting the "Calculate total row count" button, an X button appears. However, clicking the X button does not revert it back to the original. This issue did not exist in version 25.3.2 but exists in subsequent versions 25.3.3 and 26.0.1. This is unrelated to the fix in this PR. Attached below is a screenshot showcasing the instance.