Repository navigation
SQLRDD: LastRec() as the table's highest record number, "" for DBOI_CONDITION without FOR condition - #2115
Merged
RobertvanderHulst merged 2 commits intoOct 24, 2026
Conversation
… FOR condition A tag without FOR condition kept Condition = null, so OrderInfo(DBOI_CONDITION) returned NIL where DBF/ADS return "". Code that passes the result straight to string functions failed, e.g. StrTran(OrderInfo(DBOI_CONDITION,,n), ...) raised an argument error for every table in a generic "choose order" dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n DBF RecCount returned the row count of the current order (FOR condition, scope). With a conditional order this is smaller than the highest record number, so RecNo at EOF (RecCount+1) was the number of a real record, and records with a number above RecCount looked like they were past the end of the table: a browser on an order with condition typ='L' (60 of 63 rows) skipped record 61 and then showed only record 62. RecCount now reports MAX(recno column) for the whole table (COUNT(*) without a recno column), independent of order, condition and scope. It is queried on demand, cached, raised on Append() and requeried after an order change, Zap() or Pack(). Paging and EOF detection keep using the order's row count. 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.
Two ADS/DBF compatibility fixes found with a generic table browser (bBrowser) on SQLRDD tables. Both are independent of each other; base is
dev.1.
OrderInfo(DBOI_CONDITION)returned NIL for a tag without FOR conditionSqlDbOrder:Conditionis only set bySetCondition()for a non-empty condition, so for an unconditional tag it staysnullandDBOI_CONDITIONreturned NIL. DBF/ADS return"". Code that passes the result straight to a string function failed, e.g.raised an argument error (
uTarget) for every table in a "choose order" dialog.DBOI_CONDITIONandDBOI_EXPRESSIONnow return""instead ofnull.2.
LastRec()/RecCountis the table's highest record number, as in DBFRecCountreturned the row count of the current order, including its FOR condition and scope. With a conditional order this is smaller than the highest record number. Two consequences:RecNoat EOF (RecCount + 1) was the number of a real record.RecCountlooked like they were past the end of the table.Example: ADRESSDB has 63 rows. Its order has the condition
typ='L'and contains 60 of them.LastRec()was 60, the last two records of the order have the numbers 61 and 62, and the phantom record at EOF also had number 61. A browser on that order skipped record 61 and then showed only record 62.RecCountnow reportsMAX(<recno column>)for the whole table (COUNT(*)when there is no recno column), independent of order, condition and scope. That is the same asLastRec()under DBF: no record number is ever above it, andRecNoat EOF is alwaysLastRec() + 1. The value is:Append(),Zap()orPack()(_CloseCursor()).Paging and EOF detection keep using the order's row count (
_serverReccount, now read through_OrderRowCount()whereRecCountwas used internally).Testing
Skip(1)/Skip(-n)refills,OrderKeyNo/OrderKeyGoto,GoBottom,GoTo(0),GoTo(n)+Skip.LastRec()is now 63,RecNoat EOF 64.GoTo(0), order switches, decimal columns) gives identical results before and after the change.🤖 Generated with Claude Code