You are not logged in.
Pages: 1
Good day. I use the following code.
TSQLRecordOtchet = class(TSQLRecord)
private
fOtchety_nastrk : Variant;
public
constructor Create; override;
published
property Otchety_nastrk : Variant read fOtchety_nastrk write fOtchety_nastrk;
constructor TSQLRecordOtchet.Create;
begin
inherited;
fOtchety_nastrk:=TDocVariant.New;
end;
and when I created a record with
rec:=TSQLRecordOtchet.Create, then I get rec.Otchety_nastrk = 'null', but
when I created a record already with
rec:=TSQLRecordOtchet.Create(DataBase,ID), then I get rec.Otchety_nastrk = null, i.e. without quotes.
And if I want assign rec.Otchety_nastrk.Href:='http://...' I get exception "Invalid variant type 1 invoke"
In then first case, after create rec.Otchety_nastrk.Href:='http://...' it's ok. {Href:'http://...'}
Offline
TSQLRecordOtchet.Create(DataBase,ID) does read the Otchety_nastrk value from the DB, so it is set back to null, which is the value from the DB.
There is no way to force the variant field to be a TDocVariant.
As stated by the documentation, a variant field can be any kind of variant: null, a number, a string, or a TDocVariant.
There is no direct way to force the field to be a TDocVariant at all time.
In all cases, you should better not use TDocVariant.New in the constructor, but assume it is null by default, then explicitly check for VarIsNull() and set TDocVariant.New/_JSON to initialize it.
It may be possible to add a custom type, so that the published field may be a TDocVariant object or array...
But it would request a lot of code modification, and a new class inheriting from TSQLPropInfoRTTIVariant.
You may create a feature request ticket in http://synopse.info/fossil/tktnew
Offline
thank you for quick answer
Offline
Pages: 1