[fcl-db] Setting TParam.DataType to the same value clears the param value if it cannot be represented as variant
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
If you do:
Q.Params[0].DataType := Q.Params[0].DataType
it deletes the param content if it cannot be represented as variant.
Steps to reproduce:
program 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 information:
Patch attached.
Mantis conversion info:
- Mantis ID: 33710
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 38949 (#fc2516d7)
- Target version: 3.2.0