Page 1 of 1

[patch_done] Possible bug with ZTokenizer and table names

Posted: 30.06.2008, 15:36
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

Posted: 04.07.2008, 09:27
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

Posted: 06.07.2008, 00:23
by mdaems
Patch to be tested. No time now. Moved topic to User Patches...

Mark

Posted: 14.07.2008, 23:46
by mdaems
I did commit this patch and added a Test case for the Test suite.
SVN Rev. 390.

Mark