TClientDataSet.Locate raises instead of returning False when the matching row is excluded by the active Filter
Locate is a Boolean function whose contract (Embarcadero's TCustomClientDataSet.Locate docs) is: True if a matching record is found and made current, otherwise False. In TMS WEB Core it does not honour that contract when a filter is active.
It appears to search the unfiltered rows, so it finds a record that the current filter excludes. It then tries to make that record current, and that fails because the cursor operates on the filtered view — the row isn't there. The result is EDatabaseError: Could not find the requested record. (raised from Resync, via GotoBookmark) instead of Locate returning False.
VCL's TCustomClientDataSet does not behave this way: its LocateRecord runs FDSCursor.LocateWithFilter on the same cursor the active filter is installed on, so a filtered-out row is simply not found and Locate returns False. No exception.
Expected: Locate returns False.
Actual: EDatabaseError raised.
Attached is a minimal project (TWebClientDataSet, three rows loaded from inline JSON, Filter = 'Ref > 0', then Locate('Ref', -1, [])). Log output:
--- Filtered = True, Filter = 'Ref > 0', RecordCount = 2 ---
Locate (Ref = 1) returned True
Locate (Ref = -1) RAISED EDatabaseError: Could not find the requested record.
I have over 20 Locate call sites in this application, all written against the documented contract (if not X.Locate (...) then Exit). I've had to work around it by overriding Locate in my TClientDataSet descendant to catch the exception and return False.
cds.zip (11.6 KB)