Menu

#49 OrderByClause.AsString:='' fails

open
nobody
None
5
2005-09-20
2005-09-20
No

OrderByClause.AsString:='' fails. The message is:
"ORDER BY": First symbol is not "ORDER".

Moreover, when trying to assign OrderByClause.AsString:
='ORDER BY', no error message ocuurs, but the resulting
statement text (TgaSelectSQLStatement.AsString)
contains "ORDER BY" in the end, which, I believe, is
incorrect.

The first issue seems to be solved by adding

if (AItem.TokenType <> stPlaceHolder) then

to line 279 of gaSQLParserHelperClasses.pas, so that
TgaSQLStatementPartList.SetAsString becomes this:

procedure TgaSQLStatementPartList.SetAsString(const
Value: string);
var
tmpTokenList: TgaSQLTokenHolderList;
AItem: TgaSQLTokenObj;
begin
tmpTokenList := TgaSQLTokenHolderList.Create(nil);
try
ParseStringToTokens(Value, tmpTokenList);
TrimTokenList(tmpTokenList, True, [stEnd]);
if tmpTokenList.Count = 0 then
tmpTokenList.AddToken(TgaSQLTokenObj.
CreatePlaceHolder)
else if tmpTokenList.LastItem.TokenType <>
stDelimitier then
tmpTokenList.AddToken(TgaSQLTokenObj.
CreateDelimitier);
RestartParse;
tmpTokenList.First;
while not tmpTokenList.Eof do
begin
AItem := tmpTokenList.CurrentItem;
TokenList.Add(AItem);
// #Todo2 this can be optimized
OwnerStatement.CurrentSQL.Locate(AItem);
if (AItem.TokenType <> stPlaceHolder) then
ExecuteTokenAdded(Self, AItem);
tmpTokenList.Next;
end;
finally
tmpTokenList.Free;
end;
end;

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.