View Issue Details

IDProjectCategoryView StatusLast Update
0033710FPCFCLpublic2018-05-08 14:04
ReporterOndrej PokornyAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0033710: [fcl-db] Setting TParam.DataType to the same value clears the param value if it cannot be represented as variant
DescriptionIf you do:

Q.Params[0].DataType := Q.Params[0].DataType

it deletes the param content if it cannot be represented as variant.
Steps To Reproduceprogram DBLargeInt;

uses
  DB, SQLDB;
var
  Q: TSQLQuery;
  I: LargeInt;
begin
  Q := TSQLQuery.Create(nil);
  Q.SQL.Text := 'SELECT :PARAM';
  Q.Params[0].AsLargeInt := High(Int64);
  I := Q.Params[0].AsLargeInt;
  WriteLn(I);
  if Q.Params[0].DataType <> ftLargeint then // this is OK -> just check that type is ftLargeint
    Halt(2);
  Q.Params[0].DataType := Q.Params[0].DataType; // setting the same datatype clears the value
  WriteLn(Q.Params[0].AsLargeInt);
  if I<>Q.Params[0].AsLargeInt then
    Halt(1);
  Q.Free;
end.
Additional InformationPatch attached.
TagsNo tags attached.
Fixed in Revision38949
FPCOldBugId
FPCTarget
Attached Files
  • dsparams-01.patch (399 bytes)
    Index: packages/fcl-db/src/base/dsparams.inc
    ===================================================================
    --- packages/fcl-db/src/base/dsparams.inc	(revision 38948)
    +++ packages/fcl-db/src/base/dsparams.inc	(working copy)
    @@ -840,6 +840,7 @@
       VT : Integer;
     
     begin
    +  if FDataType=AValue then Exit;
       FDataType:=AValue;
       VT:=FieldTypetoVariantMap[AValue];
       If (VT=varError) then
    
    dsparams-01.patch (399 bytes)

Activities

Ondrej Pokorny

2018-05-08 13:05

developer  

dsparams-01.patch (399 bytes)
Index: packages/fcl-db/src/base/dsparams.inc
===================================================================
--- packages/fcl-db/src/base/dsparams.inc	(revision 38948)
+++ packages/fcl-db/src/base/dsparams.inc	(working copy)
@@ -840,6 +840,7 @@
   VT : Integer;
 
 begin
+  if FDataType=AValue then Exit;
   FDataType:=AValue;
   VT:=FieldTypetoVariantMap[AValue];
   If (VT=varError) then
dsparams-01.patch (399 bytes)

Michael Van Canneyt

2018-05-08 13:41

administrator   ~0108200

Applied, thank you very much !

Ondrej Pokorny

2018-05-08 14:04

developer   ~0108202

Thank you for the fast resolve.

Issue History

Date Modified Username Field Change
2018-05-08 13:05 Ondrej Pokorny New Issue
2018-05-08 13:05 Ondrej Pokorny File Added: dsparams-01.patch
2018-05-08 13:39 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-05-08 13:39 Michael Van Canneyt Status new => assigned
2018-05-08 13:41 Michael Van Canneyt Fixed in Revision => 38949
2018-05-08 13:41 Michael Van Canneyt Note Added: 0108200
2018-05-08 13:41 Michael Van Canneyt Status assigned => resolved
2018-05-08 13:41 Michael Van Canneyt Fixed in Version => 3.1.1
2018-05-08 13:41 Michael Van Canneyt Resolution open => fixed
2018-05-08 13:41 Michael Van Canneyt Target Version => 3.2.0
2018-05-08 14:04 Ondrej Pokorny Note Added: 0108202
2018-05-08 14:04 Ondrej Pokorny Status resolved => closed