You are not logged in.
Pages: 1
Thanks ab, using a variant field and assigning a dynamic array to the field, it worked.
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'?
Sorry for the code posting directly. Thanks for the quick response, it worked using local dynamic arrays.
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;
Try this.
MyGrid.DataSource.DataSet := JSONToDataSet(self, MyModelHttpClient.RetrieveListJSON(TSQLMyRecord,'',''));
Hi Rodrigo, see the TDocVariantData "count" method.
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
Many thanks for your always quick response.
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.
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
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
Thanks for the quick reply. Your tip worked very well.
AddFilterOrValidate('logonname', TSynValidateText.Create('{"MinLength":5,"MaxSpaceCount":0}'));
I'm trying to set a validation using InternalDefineModel and AddFilterOrValidate('LogonName', TSynValidatePatternI.Create('[! ]')). Which would be the correct pattern to disallow space characters?
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();
}
It would be possible to call a procedure or function of a TMVCApplication from a javascript?
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.
Pages: 1