mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-24 02:11:43 +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
|
case p^ of
|
||||||
'''', '"', '`':
|
'''', '"', '`':
|
||||||
begin
|
begin
|
||||||
|
Result := True;
|
||||||
// single quote, double quote or backtick delimited string
|
// single quote, double quote or backtick delimited string
|
||||||
SkipQuotesString(p, p^, EscapeSlash, EscapeRepeat);
|
SkipQuotesString(p, p^, EscapeSlash, EscapeRepeat);
|
||||||
Result := True;
|
|
||||||
end;
|
end;
|
||||||
'-': // possible start of -- comment
|
'-': // possible start of -- comment
|
||||||
begin
|
begin
|
||||||
@ -315,7 +315,7 @@ begin
|
|||||||
p:=PChar(SQL);
|
p:=PChar(SQL);
|
||||||
BufStart:=p; // used to calculate ParamPart.Start values
|
BufStart:=p; // used to calculate ParamPart.Start values
|
||||||
repeat
|
repeat
|
||||||
SkipComments(p,EscapeSlash,EscapeRepeat);
|
while SkipComments(p,EscapeSlash,EscapeRepeat) do ;
|
||||||
case p^ of
|
case p^ of
|
||||||
':','?': // parameter
|
':','?': // parameter
|
||||||
begin
|
begin
|
||||||
@ -403,7 +403,7 @@ begin
|
|||||||
Dec(NewQueryLength,p-ParamNameStart);
|
Dec(NewQueryLength,p-ParamNameStart);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
#0:Break;
|
#0:Break; // end of SQL
|
||||||
else
|
else
|
||||||
Inc(p);
|
Inc(p);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -145,6 +145,9 @@ begin
|
|||||||
// Bracketed comment
|
// Bracketed comment
|
||||||
AssertEquals( 'select * from table where id=/*comment :c*/$1-$2',
|
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));
|
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;
|
Params.Free;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user