[patch_done] Possible bug with ZTokenizer and table names

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
FrankSL
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 21.03.2008, 11:40

[patch_done] Possible bug with ZTokenizer and table names

Post by FrankSL »

Hi,
I have a lot of troubles while working with TZQuery objects that use tables with names that start with a number, ie. 01TabName.
Trying to debug the code I noticed that a query like:
"SELECT * FROM 01TabName"
gets tokenized wrongly and the table name becomes only "TabName", leaving "01" as an independent token.
That's because TZNumberState.NextToken gets called while tokenizing the table name.

Actually I'm using 'ado' on a MsAccess db on the 'testing' branch but I suppose this is db independent. The problems I have is that I cannot update any field because they are ReadOnly by default. From what I understand this is due to the fact that zeos cannot build updates because it hasn't the correct table name.

Thanks,
Frank
FrankSL
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 21.03.2008, 11:40

Post by FrankSL »

I did some hacking and made a patch to TZTokenizer.TokenizeStreamToList that joins two tokens if the first is a ttInteger and the next a ttWord. I'm testing it and it looks like it works in my environment.

Code: Select all

Index: ZTokenizer.pas
===================================================================
--- ZTokenizer.pas	(revisione 384)
+++ ZTokenizer.pas	(copia locale)
@@ -1317,6 +1317,11 @@
         and (toUnifyNumbers in Options) then
         Token.TokenType := ttNumber;
       { Add a read token. }
+      if ((Token.TokenType = ttWord)and(LastTokenType = ttInteger)) then
+      begin
+        Token.Value := Result[Result.Count-1] + Token.Value;
+        Result.Delete(Result.Count-1);
+      end;
       LastTokenType := Token.TokenType;
       Result.AddObject(Token.Value, TObject(Ord(Token.TokenType)));
     end
Thanks,
Frank
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Patch to be tested. No time now. Moved topic to User Patches...

Mark
Image
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I did commit this patch and added a Test case for the Test suite.
SVN Rev. 390.

Mark
Image
Post Reply