mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 23:29:15 +02:00
fcl-db: fix parameter parsing in case, when in SQL follows two comments, where in 2nd commend is embeded quote char. Bug #22463
git-svn-id: trunk@31155 -
This commit is contained in:
parent
3a746b76fa
commit
2f97bc7f60
@ -235,9 +235,9 @@ begin
|
||||
case p^ of
|
||||
'''', '"', '`':
|
||||
begin
|
||||
Result := True;
|
||||
// single quote, double quote or backtick delimited string
|
||||
SkipQuotesString(p, p^, EscapeSlash, EscapeRepeat);
|
||||
Result := True;
|
||||
end;
|
||||
'-': // possible start of -- comment
|
||||
begin
|
||||
@ -315,7 +315,7 @@ begin
|
||||
p:=PChar(SQL);
|
||||
BufStart:=p; // used to calculate ParamPart.Start values
|
||||
repeat
|
||||
SkipComments(p,EscapeSlash,EscapeRepeat);
|
||||
while SkipComments(p,EscapeSlash,EscapeRepeat) do ;
|
||||
case p^ of
|
||||
':','?': // parameter
|
||||
begin
|
||||
@ -403,7 +403,7 @@ begin
|
||||
Dec(NewQueryLength,p-ParamNameStart);
|
||||
end;
|
||||
end;
|
||||
#0:Break;
|
||||
#0:Break; // end of SQL
|
||||
else
|
||||
Inc(p);
|
||||
end;
|
||||
|
@ -145,6 +145,9 @@ begin
|
||||
// Bracketed comment
|
||||
AssertEquals( 'select * from table where id=/*comment :c*/$1-$2',
|
||||
Params.ParseSQL('select * from table where id=/*comment :c*/:a-:b', True, True, True, psPostgreSQL));
|
||||
// Consecutive comments, with quote in second comment
|
||||
AssertEquals( '--c1'#10'--c'''#10'select '':a'' from table where id=$1',
|
||||
Params.ParseSQL('--c1'#10'--c'''#10'select '':a'' from table where id=:id', True, True, True, psPostgreSQL));
|
||||
|
||||
Params.Free;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user