diff --git a/packages/fcl-db/src/base/dsparams.inc b/packages/fcl-db/src/base/dsparams.inc index 0e42c669a4..59a04d4220 100644 --- a/packages/fcl-db/src/base/dsparams.inc +++ b/packages/fcl-db/src/base/dsparams.inc @@ -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 diff --git a/packages/fcl-db/tests/testbasics.pas b/packages/fcl-db/tests/testbasics.pas index 355993a28e..75af935b9a 100644 --- a/packages/fcl-db/tests/testbasics.pas +++ b/packages/fcl-db/tests/testbasics.pas @@ -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;