diff --git a/packages/fcl-db/src/base/dsparams.inc b/packages/fcl-db/src/base/dsparams.inc index 7cc5665e2f..c6c1e6a254 100644 --- a/packages/fcl-db/src/base/dsparams.inc +++ b/packages/fcl-db/src/base/dsparams.inc @@ -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; diff --git a/packages/fcl-db/tests/testbasics.pas b/packages/fcl-db/tests/testbasics.pas index 8ec0640e4d..6fa029435e 100644 --- a/packages/fcl-db/tests/testbasics.pas +++ b/packages/fcl-db/tests/testbasics.pas @@ -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;