fcl-db: fix parameter parsing if form "-:param" is used. Do not confuse with simple line comment, which must start with "--". Bug #25505

git-svn-id: trunk@26412 -
This commit is contained in:
lacak 2014-01-08 19:59:18 +00:00
parent d87c503881
commit 336056ba2b
2 changed files with 10 additions and 2 deletions

View File

@ -208,9 +208,9 @@ begin
Result := True;
repeat // skip until at end of line
Inc(p);
until p^ in [#10, #0];
until p^ in [#10, #13, #0];
while p^ in [#10, #13] do Inc(p); // newline is part of comment
end;
if p^<>#0 then Inc(p); // newline is part of comment
end;
'/': // possible start of /* */ comment
begin

View File

@ -117,6 +117,14 @@ begin
AssertEquals( StringReplace(SQLStr, ':par', '$', [rfReplaceAll]),
Params.ParseSQL(SQLStr, True, True, True, psPostgreSQL) );
// Test comments:
// Simple comment
AssertEquals( 'select * from table where id= --comment :c'#10'$1-$2 or id= --:c'#13'-$3',
Params.ParseSQL('select * from table where id= --comment :c'#10':a-:b or id= --:c'#13'-:d', True, True, True, psPostgreSQL));
// 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));
Params.Free;
end;