[patch_done] TZSQLProcessor Tokenizer problem and decision
Posted: 28.08.2008, 15:12
The problem is in ZSQLStrings module near line 335.
The original code is:
As we can see, AbstractRODataset and every its decsendant will get right Tokenizer, but SQLProcessor will get only CommonTokenizer wich cannot understad escaped quotes like \' in PostgreSQL (for example).
Here is my suggestion:
Also we should change some lines in ZSQLProcessor unit to initialize field FDataset of ZSQLProcessor correctly.
Near line 161
and near line 369
So, I ask any person on this forum who can accept patches to ZeosLib to review my patch and accept it, if it seems to be useful.
The original code is:
Code: Select all
Tokenizer := CommonTokenizer;
if FDataset is TZAbstractRODataset then
begin
if Assigned(TZAbstractRODataset(FDataset).Connection) then
begin
Driver := TZAbstractRODataset(FDataset).Connection.DbcDriver;
if Assigned(Driver) then
Tokenizer := Driver.GetTokenizer;
end;
end;
Here is my suggestion:
Code: Select all
Tokenizer := CommonTokenizer;
if FDataset is TZAbstractRODataset then
begin
if Assigned(TZAbstractRODataset(FDataset).Connection) then
begin
Driver := TZAbstractRODataset(FDataset).Connection.DbcDriver;
if Assigned(Driver) then
Tokenizer := Driver.GetTokenizer;
end;
end
else if FDataset is TZSQLProcessor then
begin
if Assigned(TZSQLProcessor(FDataset).Connection) then
begin
Driver := TZSQLProcessor(FDataset).Connection.DbcDriver;
if Assigned(Driver) then
Tokenizer := Driver.GetTokenizer;
end;
end;
Near line 161
Code: Select all
constructor TZSQLProcessor.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FParams := TParams.Create(Self);
FScript := TZSQLStrings.Create;
FScript.Dataset := Self; //----- add this ----
FScript.OnChange := UpdateSQLStrings;
FScriptParser := TZSQLScriptParser.Create;
FScriptParser.DelimiterType := dtDefault;
FScriptParser.Delimiter := ';';
FScriptParser.CleanupStatements := False;
end;
Code: Select all
SQL := TZSQLStrings.Create;
SQL.Dataset := Self; //----- add this -----
SQL.ParamCheck := FScript.ParamCheck;
SQL.MultiStatements := False;