Repository navigation
SQLRDD: keep the rest of a FOR condition after a parenthesized group - #2118
Merged
RobertvanderHulst merged 1 commit intoOct 24, 2026
Merged
Conversation
SqlDbExpression.GetExpression() treated every EoExpr token as the end of the
expression, including the ")" of a plain parenthesized group. A condition like
!(LKNZ=='') .AND. (UST==1) was therefore translated to Not ([LKNZ] = '') and the
order silently contained rows the DBF/ADS index does not (LANDDB: 38 keys
instead of 4). GetExpression now counts the groups it opens and only ends the
expression at an EoExpr that does not close one of them.
SQLKey stripped an outer pair of parentheses whenever the text started with "("
and ended with ")", which turns "(A) AND (B)" into "A) AND (B" once the whole
condition is kept; it now strips them only when they enclose the whole text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A FOR condition was cut off after its first parenthesized group. Base is
dev; independent of #2115 and #2116.Problem
SqlDbExpression.GetExpression()ended the expression at everyEoExprtoken. That is right for the end of a function argument, but the tokenizer also emitsEoExprfor the)of a plain group. Everything after the first group was dropped without an error:The order then contained rows that the DBF/ADS index does not. Example: LANDDB has 252 rows; the tag above should contain 4 of them, the SQLRDD order contained 38. Any condition of the form
!(...) .AND. ...,(... .OR. ...) .AND. ...orEMPTY(x)rewritten as(x == '') .AND. ...was affected.Fix
GetExpression()counts the groups it opens (BoExprwith(). AnEoExprwith)closes one of these groups. Only anEoExprthat closes no group still ends the expression. Function arguments behave as before.SQLKeyremoved the outer parentheses whenever the text started with(and ended with). Now that the whole condition is kept, that turns(A) AND (B)intoA) AND (B. It now removes them only when they enclose the whole text (new helperIsEnclosed(), which skips string literals).Testing
Tested against an ERP with 297 tables and about 1065 tags, imported from DBF into SQL Server. For every tag I compared
OrderKeyCount()on the SQLRDD with DBFCDX on the original CDX.4 tables could not be compared tag by tag: their CDX contains ADS full-text (FTS) indexes on memo fields, which DBFCDX cannot open. On those tables only the row counts and navigation were checked.
🤖 Generated with Claude Code