Page 1 of 1

[patch_done] AnyZQuery.Locate not working

Posted: 15.10.2012, 20:06
by 7bit
Does not work if Keyvalues ​​- an array that contains the text of the Nationals. The problem is that it compares the text encodings. Maybe the problem is TZSoftVariantManager.Convert. These are:
...
vtUnicodeString:
Result.VString: = {$ IF[s]N[/s]DEF DELPHI12_UP} UTF8Encode {$ ENDIF} (Value.VUnicodeString);
...

P.S. Lazarus 1.0. Zeos 7.0.1b

Posted: 16.10.2012, 05:12
by EgonHugeist
7bit,

is it possible you've used the locate/filter on a non windows plattform? Or does this issue happens allways?

I've the impression your suggestion won't fix the issue because the ZVariantType vtUnicodeString shouldn't be used for FPC except you use TZConnection.UTF8AsWidstring. Do you?

My idea is much mure an missing unit cwstring (widestring-manager unit which handles UTF8ToAnsi/AnsiToUTF8 etc) in ZDatasetUtils.pas.

As far as i do understand the FPC docs is this unit needed to have success with the charconverting on the other hand functions like AnsStrLCompare ets won't be successfull.

Can you test my suggestion?

Posted: 16.10.2012, 17:32
by 7bit
I can not test your suggestion. I use the platform Windows.
I was wrong. I do not quite understand how the type Variant. Locate works if KeyValues ​​- string. But if KeyValues ​​is an array, such as an array of one element ['Text'], then Locate not working. Debugging function DecodeVariant, I found that in the first case the parameter type varString, and in the second varOleStr. Why? ..
Attached example.

P.S. In 7.0.0a all worked

Posted: 16.10.2012, 22:30
by EgonHugeist
7bit,

i've testet your app. And you are right we can't loacate the values. I'll check the issue tommorow. the varOleStr will be assumed by the FPC for you national char string. To avoid that Variant type you could use VarArrayOf([UTF8Encode(WideString('Арбуз'))]). So we do compare ststring=stString. That might be a new behavior with the FPC.

I' wondering why the second locate works like expected or better: Why does the FPC NOT assumes varOleStr again like in the VarArray? Bug?

Well i've to check what String type is used for varOleStr. Delphi uses the WideString here so the comparsion is correct. Does the FPC use a 1Byte-String instead?

Any proposals?

Posted: 18.10.2012, 20:41
by EgonHugeist
7bit,

i did check a lot but a !real! solution was NOT to find. So i've added a new define WITH_FPC_VARARRAY_BUG to improve this issue. Your solution seems to be the only one which solves the issue on our side. BUT the problem 'em selves is NOT a Zeos-Issue. It is really an FPC bug with the VarArrayOf function.

Today morning i wanted to open an issue report on the FPC bugtracker accordingly this issue. But i found this: http://bugs.freepascal.org/view.php?id=23149. Is that your issue report?

Anyway i hope this improvement does not make trouble on other places. If so then i'll remove it again, ok?

Patch done R1923 \testing

can you confirm the issue is solved/improved?

Posted: 19.10.2012, 14:08
by ism

Posted: 19.10.2012, 14:48
by ism
I tested R1923 \testing all working

Posted: 19.10.2012, 17:13
by 7bit
EgonHugeist,

All working. Yes, this is my issue. I understood why VarType (VarArrayOf (['Text']) [0]) = varOleStr. VarArrayOf calls VarArrayCreate (... vtVariant). In FPC string assigned to the element of the array (array vtVariant), transforming function VarToWideStr (Module Variants procedure sysvararrayput). But the problem that I have not decided. In short, was drowned in the code.