Closed cpyrgas closed 2 weeks ago
There are also some more incompatibilities, but VO's behavior looks crazy for most, so not sure if we should deal with those:
Passing the string as filter to the first param (which should accept a codeblock) of DBSetFilter() with for example DBSetFilter("alltrim(fld)=='bbb'") results to a runtime "Syntax Error" in VO, with message "Error setting filter". In X#, this works without errors, even though the type of the argument to the function was wrong. Not sure if we should change that.
For some bizarre reason, VO for this code:
DbSetFilter(,".T.")
DbGotop()
? EOF()
DbSetFilter(,".F.")
DbGotop()
? EOF()
DbSetFilter(,"1==2")
DbGotop()
? EOF()
DbSetFilter(,"1==1")
DbGotop()
? EOF()
DbSetFilter(,"SOMEINVALIDFILTER")
DbGotop()
? EOF()
returns T,T,T,F,F for DBFCDX and F,F,F,F,F for DBFNTX!!! None of the two make any sense, so I guess we should ignore this.
Robert, sorry, the "runtime exception" comments in the code in https://github.com/X-Sharp/XSharpPublic/issues/1489#issuecomment-2175768911 were a leftover from previous tests, will fix that. None of those produce an exception in X#, it's just different behavior to (the very bizarre behavior of) VO.
X# produces a runtime exception only for the original report https://github.com/X-Sharp/XSharpPublic/issues/1489#issue-2359521275, DBSetFilter() with whitespace for the filter string, which is the main problem.
The problem with the white space should be fairly easy to fix. There is already the following code:
FUNCTION DbSetFilter(cbCondition, cCondition) AS LOGIC CLIPPER
LOCAL sCondition AS STRING
LOCAL cbCond AS CODEBLOCK
if PCount() == 0 .or. (cbCondition:IsNil .and. cCondition:IsNil)
return DbClearFilter()
endif
We can add a condition there to test for an empty string.
OK, done, but this exposed a deeper serious issue with DBSetFilter(), I opened https://github.com/X-Sharp/XSharpPublic/issues/1493 for it
Main problem is that using DBSetFilter() with an empty or whitespace string results to a runtime exception. VO seems to clear the filter in this case: