2
0
Эх сурвалжийг харах

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 -
lacak 11 жил өмнө
parent
commit
336056ba2b

+ 2 - 2
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

+ 8 - 0
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;