Bug: Calling TZTable.Refresh will ignore #'s in FIELDNAMEs

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
rfwoolf
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 28.09.2008, 20:46

Bug: Calling TZTable.Refresh will ignore #'s in FIELDNAMEs

Post by rfwoolf »

I am running Firebird 2.1. I have a table with a field "ESTIMATEITEM#" - everything is working fine but if I specifically call .REFRESH it generates an error "Project XXX raised exception class EDatabaseError with message 'TABLE: Field 'ESTIMATEITEM' not found'.

As you can see it is cutting of the '#' in the SQL.
I have verified this with tests.

How to solve?
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

Take a look at the Tokenizer.pas

Search

constructor TZWordState.Create;
begin
SetWordChars(#0, #255, False);
SetWordChars('a', 'z', True);
SetWordChars('A', 'Z', True);
SetWordChars('0', '9', True);
SetWordChars('-', '-', True);
SetWordChars('_', '_', True);
SetWordChars(#39, #39, True);
SetWordChars(Char($c0), Char($ff), True);
end;

Here is the place where add

SetWordChars('#', '#', True);
rfwoolf
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 28.09.2008, 20:46

Post by rfwoolf »

Thanks so much seawolf. Becauase this was urgent I just went through all my fields with # in them and took out the '#' (this did unfortunately still take me a long time to do and your fix would have been much easier). Hopefully others will benefit from this in the future! :)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

This is dangerous, however. Didn't test this specific case, but mysql treats # as a comment marker. So this line should be added to your database specific tokenizer. (TZInterbaseWordState.Create)

Can you make a test case and add that to the bug tracker? Please add a table creation script so we don't depend on a specific FB version.

Mark
Image
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

A Test is almost ready, but what makes me wonder is that in Firebird # can be used as a comment .. so

Field1# as Integer

give an error, while

"Field1#" as Integer

is recognized as a valid field.

So Is it an error? Or is the normal behaviour?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Well, that means the problem is not the tokenizer but the query being fired to the server. Where the sql statement is made there must be some call to IdentifierConverter.Quote. (Search for 'quote' in the component directory and you'll find some samples)
Or, if the statement is provided by the user, he should just quote himself.

Mark
Image
Post Reply