#1 Re: mORMot 1 » Question about 'RetrieveDocVariantArray' and DynamicArray field » 2018-04-02 17:31:42

Thanks ab, using a variant field and assigning a dynamic array to the field, it worked.

#2 mORMot 1 » Question about 'RetrieveDocVariantArray' and DynamicArray field » 2018-04-02 13:28:14

mauriciobs
Replies: 2

When I use RetrieveListJson (SQLTable, '', [], '*') I get:

{"result":["[{\"ID\":1,\"Ativo\":1,\"Contatos\":\"ï¿°W3siTm9tZSI6IkFsbHlzb24gQm9yZ2VzIiwiVGVsZWZvbmVzIjpbeyJUaXBvIjoiQ09CUkFOQ0EiLCJEREQiOjgzLCJOdW1lcm8iOiI5NzQ3Ni0yNzg5In0seyJUaXBvIjoiRElSRVRPUklBIiwiREREIjo4MywiTnVtZXJvIjoiOTM0MjEtMjEzMyJ9XSwiRW1haWwiOiJhbGx5c29uQHguY29tIn0seyJOb21lIjoiRnJhbmNpc2NvIGRlIEFzc2lzIiwiVGVsZWZvbmVzIjpbXSwiRW1haWwiOiJhc3Npc0B4LmNvbSJ9XQ==\",\"Dados\":\"{\\\"LocalMapa\\\":\\\"\\\"}\"}]\n"],"id":1}

When I use RetrieveDocVariantArray (SQLTable, '', '', [], '*') I get:

{"result":[[{ID:1,Ativo:true,Contatos:null,Dados:{LocalMapa:""}}]],"id":1}

How do I retrieve the 'Contatos' field which is dynamic array using 'RetrieveDocVariantArray'?

#3 Re: mORMot 1 » How do I create a dynamic array in a property? » 2018-03-28 12:52:08

Sorry for the code posting directly. Thanks for the quick response, it worked using local dynamic arrays.

#4 mORMot 1 » How do I create a dynamic array in a property? » 2018-03-27 20:28:25

mauriciobs
Replies: 2
TTelefone = class(TSynAutoCreateFields)
protected
  fNumero: RawUTF8;
published
  property Numero: RawUTF8 read fNumero write fNumero;
end;
TTelefones = array of TTelefone;

TContato = class(TSynAutoCreateFields)
protected
  fNome: RawUTF8;
  fTelefones: TTelefones;
published
  property Nome: RawUTF8 read fNome write fNome;
  property Telefones: TTelefones read fTelefones write fTelefones;
end;
TContatos = array of TContato;

TSQLEmpresas = class(TSQLRecord)
protected
  fNome: RawUTF8;
  fContatos: TContatos;
public
  class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8;
    Options: TSQLInitializeTableOptions); override;
published
  property Nome: RawUTF8 index 80 read fnome write fnome;
  property Contatos: TContatos read fContatos write fContatos;
end;
class procedure TSQLEmpresas.InitializeTable(Server: TSQLRestServer;
  const FieldName: RawUTF8; Options: TSQLInitializeTableOptions);
var
  SQLEmpresa: TSQLEmpresas;
  Contato: TContato;
begin
  inherited InitializeTable(Server, FieldName, Options);
  if (FieldName = '') then
  begin
    SQLEmpresa := TSQLEmpresas.Create;
    try
      SQLEmpresa.Nome := 'TESTE 1';
      With SQLEmpresa.DynArray('Contatos') do begin
        Contato      := TContato.Create;
        Contato.Nome := 'EMPRESA 1';

        Contato.Telefones  <<<<<------------------ How to create dynamic array here?

        Add(Contato);
      end;
      Server.Add(SQLEmpresa, true);
    finally
      SQLEmpresa.Free;
    end;
  end;
end;

#5 Re: mORMot 1 » RetrieveListJSON and TDocVariantData » 2018-03-07 15:43:49

Try this.

MyGrid.DataSource.DataSet := JSONToDataSet(self, MyModelHttpClient.RetrieveListJSON(TSQLMyRecord,'',''));

#6 Re: mORMot 1 » RetrieveListJSON and TDocVariantData » 2018-03-05 13:46:05

Hi Rodrigo, see the TDocVariantData "count" method.

#7 Re: mORMot 1 » new book about mORMot » 2017-05-16 18:25:51

Hi Erick, congratulations on writing the book, i started to read it and would like to know how to compile one of those EnterpriseX examples in Lazarus, while compiling i got several errors in unit ewbmormot.pas and LibSodium.pas, my goal is to have the server in the Linux. Sorry for the bad english.

thanks,
Mauricio

#8 Re: mORMot 1 » Access Violation in TSQLModel.Create » 2017-01-26 13:14:48

Many thanks for your always quick response.

#9 Re: mORMot 1 » Access Violation in TSQLModel.Create » 2017-01-25 19:42:33

Zeoslib version is 7.2.1-rc and Postgresql version is 9.4. It was downloaded by fpcupdeluxe 1.2.0h. Interesting that the same version of Zeoslib downloaded by site sourceforge.net/projects/zeoslib the error does not occur.

#10 Re: mORMot 1 » Access Violation in TSQLModel.Create » 2017-01-25 19:11:21

Thank you AOG. Another error is now occurring, any idea?

An unhandled exception occurred at $006F38C9:
EZSQLException: SQL Error: ERROR:  syntax error at or near "READ"
LINE 1: ... SESSION CHARACTERISTICS AS TRANSACTION ISOLATION READ COMMI...
                                                             ^
  $006F38C9  CHECKPOSTGRESQLERROR,  line 704 of C:/fpcupdeluxe/ccr/zeos/src/dbc/ZDbcPostgr
eSqlUtils.pas
  $0061DCFD  TZPOSTGRESQLCONNECTION__SETTRANSACTIONISOLATION,  line 1093 of C:/fpcupdeluxe
/ccr/zeos/src/dbc/ZDbcPostgreSql.pas
  $005A7F31  TSQLDBZEOSCONNECTION__CREATE,  line 734 of C:/fpcupdeluxe/ccr/mORMotFPC/mORMo
t-master/SynDBZeos.pas
  $005A76DF  TSQLDBZEOSCONNECTIONPROPERTIES__NEWCONNECTION,  line 561 of C:/fpcupdeluxe/cc
r/mORMotFPC/mORMot-master/SynDBZeos.pas
  $005987EC  TSQLDBCONNECTIONPROPERTIESTHREADSAFE__THREADSAFECONNECTION,  line 6455 of C:/
fpcupdeluxe/ccr/mORMotFPC/mORMot-master/SynDB.pas
  $00598742  TSQLDBCONNECTIONPROPERTIESTHREADSAFE__GETMAINCONNECTION,  line 6438 of C:/fpc
updeluxe/ccr/mORMotFPC/mORMot-master/SynDB.pas
  $005A7414  TSQLDBZEOSCONNECTIONPROPERTIES__CREATE,  line 493 of C:/fpcupdeluxe/ccr/mORMo
tFPC/mORMot-master/SynDBZeos.pas

#11 mORMot 1 » Access Violation in TSQLModel.Create » 2017-01-25 13:44:11

mauriciobs
Replies: 6

When defining a field of the TSQlRecord class as Boolean, the following error occurs:

An unhandled exception occurred at $0047824C:
EAccessViolation: Access violation
  $0047824C  TSQLMODEL__DESTROY,  line 33081 of C:/fpcupdeluxe/ccr/mORMotFPC/mORMot-master/SQLite3/mORMot.pas
  $00477042  TSQLMODEL__CREATE,  line 32551 of C:/fpcupdeluxe/ccr/mORMotFPC/mORMot-master/SQLite3/mORMot.pas
  $005B9EC9  CREATEMODEL, line 110 of ModelCreate.pas

Here's my code:

TSQLAuthUsuario = class(TSQLRecord)
  private
    fativo: boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property ativo: boolean read fativo write fativo;
  end;

function CreateModel: TSQLModel;
begin
  result := TSQLModel.Create([TSQLAuthUsuario], 'site');  // Here the error occurs.
end;

Using mORMot 1.18.3352 FTS3
Running on Windows 7 SP1 (6.1.7601) with code page 1252
TSQLite3LibraryStatic 3.16.2 with internal MM
Generated with: Free Pascal 3.1.1 ERTTI MOP compiler

#12 Re: mORMot 1 » How not allow spaces in field content? » 2016-08-18 13:02:51

Thanks for the quick reply. Your tip worked very well.
AddFilterOrValidate('logonname', TSynValidateText.Create('{"MinLength":5,"MaxSpaceCount":0}'));

#13 mORMot 1 » How not allow spaces in field content? » 2016-08-17 20:37:59

mauriciobs
Replies: 2

I'm trying to set a validation using InternalDefineModel and AddFilterOrValidate('LogonName', TSynValidatePatternI.Create('[! ]')). Which would be the correct pattern to disallow space characters?

#14 Re: mORMot 1 » MVC Javascript question » 2016-08-08 13:23:56

Thanks for reply. I chose to create a form on the page and run the javascript code below:

callback: function() {
            document.forms["form-bridge"].action = "Logout";
            document.forms["form-bridge"].submit();
}

#15 mORMot 1 » MVC Javascript question » 2016-08-04 22:02:50

mauriciobs
Replies: 2

It would be possible to call a procedure or function of a TMVCApplication from a javascript?

#16 mORMot 1 » CreateJoined generates an "Access violation" » 2016-08-04 14:16:54

mauriciobs
Replies: 0

Hi all,
I create these two classes:

  TSQLAuthUsuario = class(TSQLAuthUser)
  private
    femail: RawUTF8;
    fativo: boolean;
  public
    class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8;
      Options: TSQLInitializeTableOptions); override;
    class procedure InternalDefineModel(Props: TSQLRecordProperties); override;
    constructor Create; override;
    destructor Destroy; override;
  published
    property email: RawUTF8 read femail write femail;
    property ativo: boolean read fativo write fativo;
  end;

  TSQLAuthGrupo = class(TSQLAuthGroup)
  private
    fServicoBloqueado: variant;
    fMenuAtivo: variant;
  public
    class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8;
      Options: TSQLInitializeTableOptions); override;
    class procedure InternalDefineModel(Props: TSQLRecordProperties); override;
    constructor Create; override;
    destructor Destroy; override;
  published
    property MenuAtivo: variant read fMenuAtivo write fMenuAtivo;
  end;

When I run the following code the error occurs:

  SQLAuthUsuario := TSQLAuthUsuario.CreateJoined(RestModel, 1);
  Writeln(#10 + SQLAuthUsuario.grouprights.Ident + #10);

If I use the primary classes TSQLAuthUser and TSQLAuthGroup works without error.

Board footer

Powered by FluxBB