VO incompatibility with longer order names
cpyrgas opened this issue · 5 comments
https://www.xsharp.eu/forum/topic?p=28980#p28980
In VO, when creating or opening an order by using order names longer than 10 characters, it truncates the names to 10 characters and the operations work without errors. In X#, they return false:
FUNCTION Start() AS INT
LOCAL cDbf AS STRING
cDbf := "c:\test\order"
FErase(cDbf + ".cdx")
DbCreate(cDbf, {{"FLD","N",1,0}})
DbUseArea(,"DBFCDX",cDbf)
DbAppend()
FieldPut(1,1)
DbAppend()
FieldPut(1,0)
DbAppend()
FieldPut(1,3)
DbAppend()
FieldPut(1,2)
? DbCreateOrder("TESTa67890",,"FLD") // TRUE, OK
? DbSetOrder("TESTa67890") // TRUE, OK
DbGoTop()
? FieldGet(1) // 0, OK
? DbSetOrder("TESTa67890dumy") // FALSE, wrong! (TRUE in VO)
DbGoTop()
? FieldGet(1) // 1, wrong, 0 in VO
? "------"
? DbCreateOrder("TESTb67890abcde",,"-FLD") // FALSE and runtime error, TRUE in VO
? DbSetOrder("TESTb67890abcde") // FALSE, wrong! (TRUE in VO)
DbGoTop()
? FieldGet(1) // 1, wrong, 3 in VO
? DbSetOrder("TESTb67890") // FALSE, wrong! (TRUE in VO)
DbGoTop()
? FieldGet(1) // 1, wrong, 3 in VO
DbCloseArea()
RETURN 0
I am not sure if I want to "fix" this. The name of the order is limited to 10 chars. Passing in a longer string is an error imho.
It is, but this is causing hidden runtime errors in apps ported from VO, which are very difficult to find by the programmer and are probably only "found" by their users instead, see https://www.xsharp.eu/forum/topic?p=28996#p28996
Ok, I will look into this. But we also need to verify what FoxPro does when creating a CDX file with > 10 chars. We may have to differentiate between the dialects for this behavior, or have different behavior in DBFCDX and DBFVFP.
I did some research and the various implementations of Xbase behave differently:
VO + Vulcan and Harbour: SetOrder with > 10 chars, ignores the extra length and matches 10 chars. CreateOrder with > 10 chars truncates to 10 chars
Xbase++: SetOrder with > 10 chars, ignores the extra length and matches 10 chars. CreateOrder with > 10 chars throws an error
FoxPro: SetOrder with 10 chars fails, INDEX ON TAG with > 10 chars throws an error
Confirmed fixed for all dialects