#1 2018-04-05 14:12:22

triguinhu
Member
From: Brazil
Registered: 2016-07-28
Posts: 27

FillOne problem with SynCrossPlatform

Hi all,

I use this code in Delphi Berlin, FMX Aplication, target Android. My device is a Zenfone 3 with Android Oreo 8.0...

procedure TFrm_Prot_Neo_01_Cli_Fire.TabLancamentosClick(Sender: TObject);
var
  ListItem: TListViewItem;
begin

  {$IFDEF MSWINDOWS}
  Lista_Cad_Neo := TSQLCad_Neo_01.CreateAndFillPrepare(Dm.BaseDados, ' ID > -1 ORDER BY ID ');
  Lista_Cad_Tipo_Cad := TSQLTipo_Cad.CreateAndFillPrepare(Dm.BaseDados, ' ID > -1 ORDER BY ID ');
  {$ENDIF}
  {$IFNDEF MSWINDOWS}
  Lista_Cad_Neo := TSQLCad_Neo_01.CreateAndFillPrepare(Dm.BaseDados, '', ' ID > -1 ORDER BY ID ', []);
  Lista_Cad_Tipo_Cad := TSQLTipo_Cad.CreateAndFillPrepare(Dm.BaseDados, '', ' ID > -1 ORDER BY ID ', []);
  {$ENDIF}

  ListLancamentos.Items.Clear;
  ListLancamentos.BeginUpdate;

  while Lista_Cad_Neo.FillOne do
  begin
     ListItem := ListLancamentos.Items.Add;
     ListItem.Text := IntToStr(Lista_Cad_Neo.ID) + ' - ' + UTF8ToString(Lista_Cad_Neo.Descricao) + ' - ' + DateToStr(Lista_Cad_Neo.Data_Cad);
  end;

end;

In FillOne line, i received in the device an error:

JSONVariantData.Data(20<>JSONVariant)

I'm attaching an image with the error screen..

Removing fillone no error occurs

In Windows 32 bit, this code works!


What could be happening? Can someone help me?

Offline

#2 2018-04-05 18:52:57

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

Re: FillOne problem with SynCrossPlatform

One of the fields of your TSQLRecords seem not handled as expected.

Offline

#3 2018-04-06 12:28:13

triguinhu
Member
From: Brazil
Registered: 2016-07-28
Posts: 27

Re: FillOne problem with SynCrossPlatform

My TSQLRecords

unit U_Cad_Neo_01;

interface

uses
  U_Tipo_Cad,
{$IFDEF MSWINDOWS}
  mORMot, SynCommons;
{$ENDIF}
{$IFNDEF MSWINDOWS}
  SynCrossPlatformREST;
{$ENDIF}

type
  TSQLCad_Neo_01 = class(TSQLRecord)
  private
    FDescricao: RawUTF8;
//    FTipo_Cad: Integer;
    FTipo_Cad: TSQLTipo_Cad;
    FData_Cad: TDateTime;
    FValor_Cad: Currency;
    {$IFDEF MSWINDOWS}
    fVersion: TRecordVersion;
    {$ENDIF}
  published
    property Descricao: RawUTF8 index 200 read FDescricao write FDescricao;
//    property Tipo_Cad: Integer read FTipo_Cad write FTipo_Cad;
    property Tipo_Cad: TSQLTipo_Cad read FTipo_Cad write FTipo_Cad;
    property Data_Cad: TDateTime read FData_Cad write FData_Cad;
    property Valor_Cad: Currency read FValor_Cad write FValor_Cad;
    {$IFDEF MSWINDOWS}
    property Version: TRecordVersion read fVersion write fVersion;
    {$ENDIF}
  end;

implementation


end.

and

unit U_Tipo_Cad;

interface

uses
{$IFDEF MSWINDOWS}
  mORMot, SynCommons;
{$ENDIF}
{$IFNDEF MSWINDOWS}
  SynCrossPlatformREST;
{$ENDIF}

type
  TSQLTipo_Cad = class(TSQLRecord)
  private
    FDescricao: RawUTF8;
    {$IFDEF MSWINDOWS}
    fVersion: TRecordVersion;
    {$ENDIF}
  published
    property Descricao: RawUTF8 index 50 read FDescricao write FDescricao;
    {$IFDEF MSWINDOWS}
    property Version: TRecordVersion read fVersion write fVersion;
    {$ENDIF}
  end;

implementation


end.

Can it be the TRecordVersion field?

Thanks Ab

Offline

#4 2018-04-06 17:27:16

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

Re: FillOne problem with SynCrossPlatform

Most probably... you are sharing not the same class between both ends.... so it is most likely to fail!

Don't leak your TSQLRecord - use dedicated SOA interface services, with proper DTO records/arrays with your clients.

Please check this discussion https://synopse.info/forum/viewtopic.ph … 991#p26991

Offline

Board footer

Powered by FluxBB