ソースを参照

* Fix for bug #27077 by Chris Rempas, plus test

git-svn-id: trunk@29111 -
michael 10 年 前
コミット
cfa859d285

+ 1 - 1
packages/fcl-db/src/sqldb/interbase/ibconnection.pp

@@ -1000,7 +1000,7 @@ begin
             if VSQLVar^.sqlscale = 0 then
               i := AParams[ParNr].AsInteger
             else
-              i := Round(AParams[ParNr].AsCurrency * IntPower10(-VSQLVar^.sqlscale));
+              i := Round(BCDToDouble(AParams[ParNr].AsFMTBCD) * IntPower10(-VSQLVar^.sqlscale)); //*any number of digits
             Move(i, VSQLVar^.SQLData^, VSQLVar^.SQLLen);
           end;
         SQL_SHORT, SQL_BOOLEAN_INTERBASE :

+ 25 - 0
packages/fcl-db/tests/testfieldtypes.pas

@@ -90,6 +90,7 @@ type
     procedure TestVarBytesParamQuery;
     procedure TestBooleanParamQuery;
     procedure TestBlobParamQuery;
+    Procedure TestFmtBCDQueryPrecision; // Bug 27077
 
     procedure TestSetBlobAsMemoParam;
     procedure TestSetBlobAsBlobParam;
@@ -1547,6 +1548,30 @@ begin
   TestXXParamQuery(ftBlob, FieldtypeDefinitions[ftBlob], testBlobValuesCount);
 end;
 
+Procedure TTestFieldTypes.TestFmtBCDQueryPrecision;
+
+begin
+  if not(SQLServerType in [ssFirebird]) then
+    Ignore(STestNotApplicable);
+  TSQLDBConnector(DBConnector).TryDropIfExist('FPDEV2');
+  TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (ID INT, FIELD1 NUMERIC (9,5))');
+  TSQLDBConnector(DBConnector).CommitDDL;
+  with TSQLDBConnector(DBConnector).Query do
+    begin
+    sql.clear;
+    sql.append('insert into FPDEV2 (ID,FIELD1) values (:id,:field1)');
+    Params.ParamByName('id').AsInteger := 1;
+    Params.ParamByName('field1').AsFMTBCD :=DoubleToBCD(1234.56781) ;
+    ExecSQL;
+    sql.clear;
+    sql.append('select * from FPDEV2 where (id=1) and (field1=1234.56781)');
+    Open;
+    AssertTrue('Expected IsNull', Not (EOF and BOF));
+    close;
+    end;
+  TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
+end;
+
 procedure TTestFieldTypes.TestStringParamQuery;
 
 begin