Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Database/TField/TBlobField    [ Add a report in this area ]  
Report #:  68658   Status: Closed
Invalid working with variants variables
Project:  Delphi Build #:  12.1
Version:    12.0 Submitted By:   Sergey Mogilnikov
Report Type:  Basic functionality failure Date Reported:  11/6/2008 5:53:00 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   267175
Resolution: As Designed (Resolution Comments) Resolved in Build: : 12.0.3338.19665
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 15
Description
Invalid read/write variant values into BLOB
Steps to Reproduce:
var
  V: Variant;
begin
  V := 1;
  cds.Append;
  cds.Edit;

  // Bug 1
  cdsBLOBField.Value := V;                 // <- This code doesn't work in Delphi 2009 but works OK in previous IDEs
  cds.FieldByName('BLOBField').Value := V; // <- This code works OK in all IDEs

  // Bug 2
  // The following condition returns True in previous IDEs
  if cds.FieldByName('BLOBField').Value = V then
    ShowMessage('Success :-)') // Appears in previous IDEs
  else
    ShowMessage('FAILED!!! :-('); // Appears in Delphi 2009
Workarounds
None
Attachment
dxSample.ZIP
Comments

Tomohiro Takahashi at 11/7/2008 7:15:56 AM -
Could you tell us more detail about 'cxVariants.pas' attached?

Sergey Mogilnikov at 11/18/2008 2:55:48 AM -
Please remove this unit file and correct the uses clause and run the project, or use an empty project and the code I wrote above to reproduce the problem.

Tomohiro Takahashi at 11/18/2008 6:00:10 PM -
Could you please optimize your sample project and attach it again?

Sergey Mogilnikov at 8/11/2010 11:15:01 PM -
I attach new project for reproduce this problem. See comments in code.

Tomohiro Takahashi at 8/12/2010 1:12:31 AM -
Unfortunately, as you know, this report was closed as 'As Designed' one year ago.
This is a comment from internal tracking system.
<<<<<<<<<
TBlobField.Value changed from being an string (AnsiString in previous releases) to being a TBytes in Delphi 2009.  This means that simple scalar types can no longer be used directly with the Value property.   A workaround is to use TMemoField instead of TBlobField.  TMemoField.Value remains an AnsiString type and the code in the steps should work properly after a fix is applied to the TBlobField.SetVarValue routine.  A patch is attached.
>>>>>>>>>

Sergey Mogilnikov at 11/18/2008 2:52:51 AM -
Please remove this unit file and correct the uses clause and run the project, or use an empty project and the code I wrote above to reproduce the problem.

Server Response from: ETNACODE01