#1 2022-07-06 15:01:37

profh
Member
Registered: 2010-07-02
Posts: 161

TRestBatch from json string

Hi ab, i got the following code:

var
  lbatch: TRestBatch;
  lrec: TOrm;
  ...
begin
  lbatch := TRestBatch.Create(DBServer.Orm,
                  DBModel.Table[ltblname],10000,
                  [boInsertOrReplace,boExtendedJson]);
  
  lrec := DBModel.Table[ltblname].CreateAndFillPrepare(ajson); 
  lrec.FillRewind;
  while lRec.FillOne  do
  begin
    lrtn := lbatch.Add(lrec,true,true);
  ......

some field values in ajson are nulls, but after execute as follow:

lrtn := DBServer.Orm.BatchSend(lbatch);

filed values in sqlite become emtpy string or zero depends on its type.

how to keep the null values into the sqlite?

Thank you very much!

Offline

#2 2022-07-07 07:22:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,656
Website

Re: TRestBatch from json string

How do you store "null" in pascal code? What is the TOrm fields definition?
There is a single way to store such value in our ORM, it is by using a NullableVariant.

See e.g. https://synopse.info/forum/viewtopic.ph … 737#p34737
and https://synopse.info/files/html/Synopse … l#TITL_177

Online

#3 2022-07-07 08:06:51

profh
Member
Registered: 2010-07-02
Posts: 161

Re: TRestBatch from json string

thanks, i will try it.

Offline

#4 2022-07-10 14:15:32

profh
Member
Registered: 2010-07-02
Posts: 161

Re: TRestBatch from json string

after change the field delfinition in TOrm to NullableUtf8text, it worked.
Thanks again!

Offline

Board footer

Powered by FluxBB