#1 2011-06-21 04:56:38

coblongpamor
Member
From: Bali-Indonesia
Registered: 2010-11-07
Posts: 130
Website

Problem with Default Value

hi,

i have problem with default value.

i add fTest field for table TSQLFile on MainDemo project like following:

TSQLFile = class(TSQLRecordSigned)
  public
    fName: RawUTF8;
    ..
    fTest:Boolean;
  published
    property Name: RawUTF8 read fName write fName;
    ...
    property Test: Boolean read fTest write fTest default True;
  end;

but if i insert new record, with ignoring Test field, the Test field is set to 0 (not 1 as expected on default value).
and if add new field (TSQLFile have contained data)

property Test2: Boolean read fTest2 write fTest2 default True;

then Test2 value will null (not 1 as expected on default value)
and then error will occured on DrawcheckBox in SQLite3UI unit.

thanks

Offline

#2 2011-06-21 05:22:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,182
Website

Re: Problem with Default Value

The default value is not set by the framework at TSQLRecord level.
It's by design, and this default property was never documented to work.

Even at the VCL level, default is only working when loading the components from a DFM stream.
When you create a TObject at runtime, its default value is not set.
The ORM has the same exact behavior: all TSQLRecord objects created don't have their default value set.

Offline

Board footer

Powered by FluxBB