#1 Re: mORMot 1 » How to get the text field from sqlite » 2019-07-08 11:47:36

ab wrote:

By definition, a RawUTF8 published property is stored as a JSON string, with espace of all JSON quotes.

I don't understand when you write "But the select using CreateAndFillPrepare function, result is blank". What does it mean?
I don't understand what you expect.

The best is to show some code to reproduce your problem, preferably not within the message post, but in https://gist.github.com/ or something similar.


I Think what he want to say ab, is , he has the FText as a Field, and inside has a JSON Array, and he wants to Use the CreateAndFillPrepare , to Select Inside this array, Like

-> This JSON as value in a Field = ["{\"Name\":\"DI_0065_0\",\"Description\":\"Something one\"}","{\"Name\":\"DI_0065_1\",\"Description\":\"Something two\"}"]

FSomeTable.CreateAndFillPrepare(FServer,'Description LIKE ? ', ['%'+aValue]);

but i don't know if it's possible, because " Description " It's not a Real Field. FText Is

#2 mORMot 1 » SQLRecord Variant property Loading to Object » 2019-07-01 14:11:25

Shadownildo
Replies: 0

Hi there, Probabily this is a Dumb question and it's not a huge problem but i don't like the way i implement, i found some solutions, but i didn't like it so much, so i'm gonna ask,

there is a Way i can parse property Variants without have to create Local Vars to them ?

  procedure RecToORM(const rec: TSQLRecordSale;out ORM: TSale);
  var
  temp : Variant;
  EmployeeRef : TEmployeeRef;
  CompanyRef: TCompanyRef;
  begin
    with ORM do
    begin
.....
      temp := rec.Company; <-- Have to Assign to a Local Variant
      ObjectLoadVariant(CompanyRef, temp); <-- Then Load a the Variant to a local var object
      Company.EIN := CompanyRef.EIN ; <-- Then i really assign to the Main object
      temp:= rec.Employee;
      ObjectLoadVariant(EmployeeRef, temp);
      Employee.Name := EmployeeRef.Name;
    

// I was thinking if there is a way to do something like
// ObjectLoadVariant(Company,Rec.Company);
// in a Single Line, but the Method don't accept.
// I find out that have some ICQRS Methods that do this, but i don't really want to change the Architecture to use them, but if it's the way, so be it. Any Suggestion?
......
    end;
  end;

#3 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-28 13:55:32

Another Update !

Already Solved all the Question's Above cool ! And just for curiosity because i think is awesome , Now Using Parallel Process and Threads, with Batch, We are Inserting 10.000.000 Millions Registers, in 6 SECONDS yikes, with a 30.000 Kb/s Server in Memory, This Speed is just WOW and with this memory is Just WOWW , Thanks For the Help big_smile !

#4 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-26 20:27:00

Another Quick Update, but the Question above still remains...

More changes, and now the server don't go more than 30.000 Kb/s , don't matter How many Registers i'm sending, last test we put 18.000.000, yes 18 Millions Registers simultaneously, This is REALLY good, BUT, for this, we are using SicClientDriven, and our Worries are about the CrossPlataform Issue, like , if using JavaScript to make a Request in our Server, The "Destruction" of this Service, have to be in the Client Side , Because of the SicClientDriven, but there is no way to do this there, So i'm wondering, The server verify this "Destruction" by Verifying the Bridge Between Client-Server, and when the request of the JavaScript Application "Ends" , it understand that have to destroy the instance?

#5 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-26 14:30:58

Quick Update, make some adaptions  in the perfomace project and now i'm using the Real server to make the tests and, i think i get rid of the leaks, Using ClearObject() in the SQLRecord, make a test with 12.000.000 of registers , Simultaneously, and All Okay!, and the Memory in the server don't go more than 100.000kb/s  for me this is a big WIN, i think this memory is a Buffer, i don't know if there is a way to ger rid of this, Thanks for the help macfly!
but taking advantage of the conversation, With the suggestion you make, i Can't make Simultaneously insertions , because of the

if  FServer.TransactionBegin(TSQLRecordSale) then
      begin
        .....
      end;
 

I search for some answers in the documentation, and is recommended to use BATCH, or use TransactionBegin on Client-side, but i don't really like to do this kind of Transaction Control in the Client, you got any suggestions how to do in the Server-Side?

  try
    .....
      try
      .......
      except
        ......
  finally
    ClearObject(aSale);
    aSale.Free; 

12.000.000 Registers

#6 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-26 12:49:15

And just to clarefy, All those others leaks, are because i'm not Destroying the Rest server, Because in a real scenario i will not destroy the Server after using a Service, only when i close the server by myself, and if i make this in the service Side

    result := false;
    if fServer.TransactionBegin(TSQLRecordSale, CONST_AUTHENTICATION_NOT_USED) then
    begin
      try
      ....
      except
      ....
      end;
    end;
  finally
    ClearObject(aSale);
    FreeMemAndNil(aSale);
    aSale.Free;
  end;
end;

And in the Client Side i Destroy the server like you suggest

      FVendaService := nil;
      RestClient.Free;
      RestServer.Free;
      Amodel.Free;

I will Not have a Leak , But, if i Comment the RestServer.Free, i will have this.

Leak

And like i said, In a real scenario, i Can't have this Those leaks in Red after using the service..

#7 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-26 12:12:54

macfly wrote:

You do not need this in Teste method:
fServer.Commit(CONST_AUTHENTICATION_NOT_USED, false);

I not see in your code where the transaction was started.

A commit must be used in conjunction with TransactionBegin.

It would make sense to use this in your TesteInsercao method.

 RestServer.TransactionBegin(...);
  for I := 0 to 4 do
  begin
      ....
      FSaleService.Teste(ObjectToJSON(sale),test);
      ....
  end;
  RestServer.Commit(...);
 // Or a RestServer.Rollback in case of errors
 // See  TransactionBegin documentation

Thanks for the Help!

Already make these Changes!, And the Leaks Decreased significantly, but the main Leak still here , this test was made with 10 Sales with 10 itens each and The type was Variant.

Main Leak

#8 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-25 20:22:49

It's really my bad, when i share the code, i change the Language for better Understandiment, and  i erase the fServer.Add() by mistaken,Sorry, but i like more the way you implemented, thanks for the Tips again!

    fServer.Add(aSale, true);
    result:= true;
    fServer.Commit(CONST_AUTHENTICATION_NOT_USED, false);

I know the Danger with Model, in the main server all the preparations are like you suggest.

#9 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-25 19:24:42

macfly wrote:

And fServer.Commit... Should be in this method?

And again i forgot to answer one , haha,
Why Shouldn't be ?
it's inside a TInjectableObjectRest Class Object, and have access to the info i need, or i mistaken ?

#10 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-25 19:18:13

macfly wrote:

What's inside the TesteInsercao method?

And (not related to leak), You are retrieving an object that probably does not exist, and then overriding the data. This is one more step that has no effect.

 aSale := TSQLRecordSale.Create(fServer, 0); <-- this issues a Retrieve from DB
 aSale.FillFrom(SaleInfo);

Would be better:

 aSale := TSQLRecordSale.Create;
 aSale.FillFrom(SaleInfo);

or simply:

 aSale := TSQLRecordSale.CreateFrom(SaleInfo);

And fServer.Commit... Should be in this method?

Thanks for the Tip!, already make the changes you suggest, with CreateFrom()!

and about the Teste Insercao Method , it has basicaly a Loop that Create a TSale Object, populate Him, and the Nested Objects Inside, and Call The insertion Service

 procedure TTestPerformanceVenda.TesteInsercao;
var
  sale: TVenda;
  RestServer: TSQLRestServerFullMemory;
  i: integer;
  RestClient: TSQLRestClientURI;
  cmd: IDomVendaCommand;
  test : Boolean;
begin
  RestServer := TSQLRestServerFullMemory.CreateWithOwnModel([TSQLRecordSale]);
  RestServer.ServiceDefine(TSaleService, [ISaleService], SicClientDriven);
  RestClient := TSQLRestClientURIDll.Create(TSQLModel.Create(RestServer.Model), @URIRequest);
  try
    RestClient.Model.Owner := RestClient;
    RestClient.ServiceDefineClientDriven(ISaleService, FSaleService);
    try
      for i := 0 to 4 do
      begin
        sale := TSale.Create;
        populateSale(i, sale); // a var Parameter
        try
           FSaleService.Teste(ObjectToJSON(sale),test);
           Check(test = true);
        finally
        ClearObject(Sale,true);
        FreeAndNil(Sale);
        end;
      end;
    finally 
      FVendaService:= nil;
      RestClient := nil;
      RestClient.Free;
    end;
  finally  
    //RestServer.Free;
  end;
end;

#11 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-25 14:24:25

macfly wrote:

It must be something that has been created but not destroyed, and it occurs as a consequence.
There are several objects that appear in the report.

Sorry , i forgot to Answer that.

The others Objects appears because i'm testing the perfomace in a Local TSQLRestServerFullMemory  Server, so i'm not destroying the Connection as should be, because, i Can't destroy a server Connection after using only one service, so FastMM4 understand as Leak

#12 Re: mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-25 14:17:58

macfly wrote:

This leak should not be related to the variants.

It must be something that has been created but not destroyed, and it occurs as a consequence.
There are several objects that appear in the report.

What is this TJSON type?
And FreeMemAndNill is your own method? JCL maybe? What he does?

Thanks for the Answer!

This amount of leaks only occurs when i change the fields RawUTF8 to Variant or Variant to RawUTF8,

The TJSON Type is a RawUTF8

   TJSON = type RawUTF8; 

and Yes FreeMemAndNill is a Own Method,but already tested with Free and FreeAndNil, Same results.

procedure FreeMemAndNil(var ptr; size: Integer = -1);
var
  p: Pointer;
begin
  p := Pointer(ptr);
  if p <> nil then
  begin
    if size > -1 then
      FreeMem(p, size)
    else
      FreeMem(p);

    Pointer(ptr) := nil;
  end;
end;

Best Regards,
Shadownildo

#13 mORMot 1 » Variant in SQLRecord MemoryLeak? » 2019-06-25 12:41:54

Shadownildo
Replies: 17

Hi There,

We are running some perfomace tests in the ours servers, With mongoDB and SQLITE, and we find out that , if we use a type Variant,in the SQLRecord for a Published Field,  there is a Gigantic Memory Leak, that we can't get rid of, it's not the Object , and i don't know where it can be

procedure TSaleService.Test(SaleInfo: TJSON; out result: Boolean);
var
  aSale: TSQLRecordSale;
begin
  try
    result := false;
    aSale := TSQLRecordSale.Create(fServer, 0);
    aSale.FillFrom(SaleInfo);
    result := true;
    fServer.Commit(CONST_AUTHENTICATION_NOT_USED, false);
  finally
    FreeMemAndNil(aSale);
  end;
end;

with this Implemantation that Works, but have a Memory Leak, not in the Object, but in a Unknow Object (it's what FastMM4 tell us), but like i said, running some tests with Variants and RawUTF8 , When we use a Variant Field, and run the perfomace test, that is like 1000+ registers , the Memory of the Server go to 1.700.000+ and don't go away
in those tests, we make 10.000 "sales", with 100 "Itens" each sale in the aggregate, is sorta 1.000.000 Registers.

Image of a Failed Test

So, we try to use RawUTF8 to "Avoid" this Memory Leak, but even so, with RawUTF8 stills a little Leak that don't go away.

Image of a Successful Test

Memory Leak Infos ( We not use 10.000 sales for this image, because take to Long to FastMM4 give me the report about the leaks, so those Reports are based in a 100 "Sales" With One Item In the Aggregate )

As you can se with the image Above, With Variants or RawUTF8 Still have a Leak, but the difference between the Leak is Gigantic, but, working with Variant is a good thing, because in Mongo (In Other types of Database(SQLITE,Postgres,etc) is all the same), i can work with the data in a better way than String(RawUTF8) but if i need to escape this Leak... i prefer to work with Strings, BUT, I Can't have this Leak in the Server, RawUTF8 Leak Less, but in a long time Online, will Give me Out Of Memory and this can't happen.... and i'm really curious, Why there is this Memory Leak, and why i can't get rid of , even if i Clear the field with Unassigned, or Cleaning the Object with ClearObject() or Freeing him,  i make a Small Project to work only with Variant's, and Creating nested Objects, and i don't have a Leak, but when come's to SQLRecord, this happen, anyone could help me ?

Sorry about the Bad English
Best Regards
Shadownildo

#14 Re: mORMot 1 » Raising http 400 in Interface-Based Service » 2019-06-21 14:33:06

tomek wrote:

Thank you all for tips and possible solutions.
The problem is, that server is made for third party client, and client side developers are quite reluctant to interpreting custom answers with http 200.

Regards, Tomek

If i understood it right, you want to do something like this ?

 if FConnection.SetUser(AAuthSettings.GetUSerName, AAuthSettings.GetPassWord) then
  begin
    aStatus := FConnection.CallBackGet(
      'Autentication', [
        'Id', AAuthSettings.GetId.ToString
      ], aOut
    );

    Result := (aStatus = 200);
    case aStatus of
      200:
      begin
        Result := True;
        AMessage := 'OK';
      end;
      400:
      begin
        Result := False;
        AMessage := 'Conection limit!';
      end;
      401:
      begin
        Result := False;
        AMessage := 'Route Blocked';
      end

#15 Re: mORMot 1 » Timeout with TSQLHttpClient on Long Query » 2019-06-14 12:13:54

pvn0 wrote:

Check your http client constructor, there are some timeout parameters there you might find useful.

As for understanding what ab said, the service method that executes on the server side should not take long, in fact, it should exit as soon as possible. If you know that it will take a long time then move (or rather schedule) the work to a worker thread instead, this avoids blocking the connection thread that received your client request and as a result, solves the timeout issue.

This introduces a different problem, how will the client know when the work has finished processing? Pooling, which is basically about asking the server for the current work status, at some interval. For example, in your service definition "TVendaService" you would define a function like "function IsWorkFinished(WorkID : Integer) : Boolean", and on the client side, call this function every X ms/sec in a timer. This is just basic example,
typically you would include status codes instead "procedure IsWorkFinished(WorkID : Integer; out Status: Integer)", like "WORK_IS_QUEUED","WORK_IS_PROCESSING","WORK_FINISHED" etc..., you get the gist.

Thanks For the Answer pvn0!

if i understand it right, it will work Like a CallBack ? that i have to a code like 

 Procedure IsWorking(const WorkID: Integer; Out Status :integer); 

that implements something like this

procedure IsWorking(WorkID : Integer; out Status: integer)
begin
if WorkId = 0 then
 break;
Status := Service.Work(workId); // Example 
end;

We are using ID to exemplify this , but How i get that ID or Name,and how i know is still Working? This part is a bit confusing for me, i understand i will have to create A Thread Pool, but how  Find the Same Work instance is what i don't know how

Sorry about fo the newbie questions and the Bad English hmm
Best Regards
Shadownildo

#16 Re: mORMot 1 » Timeout with TSQLHttpClient on Long Query » 2019-06-13 13:50:31

ab wrote:

Just use a queue and a background thread, then two methods, like MyProcessStart and IsMyProcessFinished to pool the service.

Thanks for The Answer Ab!

I'm sorry to ask this, but you have a Sample? because i can't visualize this suggestion and for me study this better ?

#17 Re: mORMot 1 » Memory Leaking using TDDDRepositoryRestFactory in the Server Side » 2019-06-13 13:01:09

jaclas wrote:

Correct the order of these lines:

  finally
   ffactory.free; //first
   ffactory := nil; //second
  end;   

Thank you For the Answer!

But ths not solve the problem sad , we are Studying the RegressionTests in dddInfraRepoUser, and thinking how manage the Memory... What happen is ,

We have a ClientDriven Service that >
Connect To the Server >
And Inside this Service, we Start Another Connection With the Own Server that Define and Call's Other Service .

function TVendaService.Include(const DadosVenda: TVenda): boolean; // This is the ClientDriven Service
var
  cmd: IDomSaleCommand;
  ffactory: TRepoSaleFactory;
begin
  ffactory := TDDDRepositoryRestFactory.Create(FServer); 
  FServer.ServiceContainer.InjectResolver([ffactory]);
  FServer.Services.Resolve(IDomSaleQuery, cmd); // This is the Inside Service that is a ICQRSService 

When we Free the ClientDriven Service, Clean the Client > Server Memory and it's OK, But, The Inside Service that is a ICQRSService ,Remains in the Memory, and Only gone if we Free the RestServer like is done in the RegressionTests in dddInfraRepoUser.pas, But in a real Scenario we can't Free the RestServer Connection after using one service hmm.

#18 mORMot 1 » Memory Leaking using TDDDRepositoryRestFactory in the Server Side » 2019-06-11 20:19:05

Shadownildo
Replies: 2

Hello Again, (Time for Multiple Posts big_smile)

So, We are consuming a Interface-Service, as Client-to-Server and Server-To-Self,In the Client-To-Server we don't have a memory Leak, and in the server-to-Self side It Works Perfectly!, BUT, i'm having some trouble with Memory Leak in the Server side with this TDDDRepositoryRestFactory, Sorry if the Code is big , if so i will put in a pastebin!

  ffactory := TDDDRepositoryRestFactory.Create(FServer); 
  FServer.ServiceContainer.InjectResolver([ffactory]);
  FServer.Services.Resolve(IDomSaleQuery, cmd);
  try
    Result := False;
    if cmd.SelectAll = CqrsSuccess then
    begin
      cmd.GetAll(Sale);
      Result := True;
    end;

  finally
   ffactory := nil;
   ffactory.free;
  end;    

and we think it might be the Repo Fault, but we didn't find the reason, any suggestion for what could be??

function TRepoVenda.GetAll(out aAllAggregate: TVendas): TCQRSResult;
begin
 Result:=  ORMGetAllAggregates(aAllAggregate);
end;
function TRepoVenda.SelectAll: TCQRSResult;
begin
  Result := ORMSelectAll('',[]);
end;           

#19 mORMot 1 » Timeout with TSQLHttpClient on Long Query » 2019-06-11 17:37:42

Shadownildo
Replies: 5

Hello Again smile

So, i'm having a little problem when I try to use a service and it takes longer than usual, I get an Exception from Time out, I know that with WebSocket i can do this, but I was wondering if there is a way to do this with httpSQLClient and httpSQLServer because I know it is not perfomatic or ideal that a query takes so long, but there will be cases that the internet may be slow in some report or something of the genre, it would not stop the Service, even if it takes a while, and i do not found anything that helps to do this in the forum and documentation ( i know Callbacks can work, but i'm trying to do without then). already try to use setTimeout with the Service but not work

 
 FactoryService := FRest.ServiceDefine(TVendaService, [IVendaService], sicClientDriven);
 FactoryService.SetTimeoutSec(99999999);       

Sorry about the Bad English
Best Regards,
Shadownildo

#20 Re: mORMot 1 » Table creation in MongoDB » 2019-06-05 13:02:43

ab wrote:

But why on earth are you expecting to have a collection appear when it is void?
As I wrote, there is no "CREATE TABLE" statement in MongoDB.
Isn't it enough to have the collection appear when there is some data within?

Yep, You are right, i make a more deep research yesterday , and find out that i was really wrong with Mongo concept... i have this solid concept with databases that must have tables, but with Mongo it's not in that way, Sorry about that Ab hmm everything is working as expected now smile

#21 Re: mORMot 1 » Table creation in MongoDB » 2019-06-04 12:18:22

A Update
Making some Tests, i find out that if i make a InitializeTable in the SQLRecord the Mongo Create the Table

class procedure TSQLTestTable.InitializeTable(Server: TSQLRestServer;
  const FieldName: RawUTF8; Options: TSQLInitializeTableOptions);
var
  Test : TSQLTESTtable;
begin
  inherited InitializeTable(Server, FieldName, Options);
 if FieldName='' then begin // new table -> create default
    Test := TSQLTestTable.Create;
    try
      Server.Add(Test,true);
    finally
      Auth.Free;
    end;
  end;
end;        

But i wonder if there is a way to do that without having to Create a Empty Document.

#22 Re: mORMot 1 » Table creation in MongoDB » 2019-06-03 17:24:39

ab wrote:

Isn't "mORMot" the database name?

No, it's a Collection
https://imgur.com/J39Vu2p ( Ignore the others Databases with Similar names, i was just trying others things )

#23 Re: mORMot 1 » Table creation in MongoDB » 2019-06-03 13:12:07

ab wrote:

What do you mean that the "table is not created"?
There is no CREATE TABLE -like statement in MongoDB.
To create a collection, you need to add items to it.

thanks for the answer ab,
Sorry about that, i know there is not a Create Table, but even if Empty Mongo Should Create the Collection right ? since AuthGroup and AuthUser don't have any item, only the indexes like , in AuthUser is created with _LogonName and _GroupRights and _id, and if i put some "Primary keys"

 Stored AS_UNIQUE 

in the SQLRecord,As I showed ealier, The collection is created, but in the exemple you asked me to run, it's created a Collection called mORMot, only with the _id Index, there is a way to accomplish that without add any item ? just creating a Collection with the default _id without any  Primary key from the table, or i really misunderstood ?

Sorry about the English
Best regards,
Shadownildo.

#24 Re: mORMot 1 » Table creation in MongoDB » 2019-05-31 15:04:12

Just to Update

we Change the Compiler, now we are Using FPC with Lazarus, with the Trunk Version of fpcupdeluxe, but with same results. Mongo still Only creating Auth Tables

#25 Re: mORMot 1 » Table creation in MongoDB » 2019-05-30 12:57:02

ab wrote:

Are you using the latest version of the framework? Currently it is 1.18.5233.
What is your compiler?
What is your MongoDB revision?
My guess is that some access right problem to your MongoDB instance.

CreateMissingTables should be called AFTER registering the external SQL connections, or MongoDB.
Modify your code to do such.

I Tried now, to do what you suggest to Call CreateMissingTables After Register The Mongo, but same results

constructor TDBInstance.Create(Root: string; MongoDB: TMongoDatabase);
begin
    aModel := DataModel(Root);
    inherited Create(aModel, SQLITE_MEMORY_DATABASE_NAME);
    StaticMongoDBRegisterAll(Self, MongoDB);
    Self.AcquireExecutionMode[execORMGet] := amBackgroundORMSharedThread;
    Self.AcquireExecutionMode[execORMWrite] := amBackgroundORMSharedThread;
    Self.DB.Synchronous := smOff;
    Self.DB.LockingMode := lmExclusive;
    Self.CreateMissingTables;
end;

#26 Re: mORMot 1 » Table creation in MongoDB » 2019-05-30 11:58:09

ab wrote:

Are you using the latest version of the framework? Currently it is 1.18.5233.
What is your compiler?
What is your MongoDB revision?
My guess is that some access right problem to your MongoDB instance.

CreateMissingTables should be called AFTER registering the external SQL connections, or MongoDB.
Modify your code to do such.


i'm in version 1.18.5232
I'm using Delphi Berlin 10.1
my mongoDB is 4.0.9 Community, and i'm using mongodb Compass to access the data

You say that i need to Call CreateMissingTables after the registering, but the Server Instance do not have a access to the Mongo Instance , it's not like Other databases like Postgres , Firebird where i inform my Props and start the server with those infos , i start the server, and then i link the Mongo Instance with the Server, or i misunderstood?, but i was debugging inside the  StaticMongoDBRegisterAll() , and i notice that the Table is Found out , and he tries to Register all the fields  , but for some reason it's not created

He Finds the Collection
https://imgur.com/LVYvZ3v

When tries to find the fields in the first BSONProjectionSet he founds
https://imgur.com/qnOTeYt

but in the Second one, only _id is found out and setted as 0, don't know why.
https://imgur.com/o7MQWnW

https://imgur.com/aCc1CMm

#27 Re: mORMot 1 » Table creation in MongoDB » 2019-05-29 20:24:27

ab wrote:

About the errors in sample 24, I can't see the image.png (not public access).

You call CreateMissingTables before StaticMongoDBRegisterAll() which is wrong.
The tables are therefore created before MongoDB is registered.

Oh, i'm sorry about that, but the errors are

! ORM with acknowledge - Retrieve from SQL
! Exception EVariantInvalidOpError raised with Message :
! Invalid variant operation

Total Failed : 1 / 11.597 - ORM with acknowledge FAILED 6.87s

2.2. ORM without acknowledge

! ORM with acknowledge - Retrieve from SQL
! Exception EVariantInvalidOpError raised with Message :
! Invalid variant operation


Total Failed : 1 / 11.597 - ORM Without acknowledge FAILED 6.87s

About the Call CreateMissingTables is because the method is for a Generic Creation of a Rest Server DB, so i use for SQLite Native, SQLite Firedac, Firebird, Postgres, MYSQL and some of they use this call, and i know that has no impact on MongoDB, what you suggest ab ?

#28 Re: mORMot 1 » Table creation in MongoDB » 2019-05-29 18:48:56

ab wrote:

Could you try to run and execute sample 24 - aka MongoDBTests.dpr ?
On my place, no problem persisting the TSQLORM class:

Using MongoDB 2.6.1 V8
Generated with: Delphi 7 32 bit compiler

Time elapsed for all tests: 691.07ms
Performed 2019-05-29 17:38:56 by User on ACER

Total assertions failed for all test suits:  0 / 25,998
! All tests passed successfully.

Then put some code to reproduce your problem in a gist - not directly in the forum message.


I got Two  errors, on this Sample
https://files.slack.com/files-pri/T7MCR … /image.png

and part of the code is this

   begin
        FServer := TDBInstance.Create(FServerInfos.Config.GetRoot);
        StaticMongoDBRegisterAll(FServer, FFactory.ConnectionNativeDBFactory.GetMongoDB.GetMongoDB.Open(FServerInfos.Config.GetDatabasepath));
        FServices := TService.Create(FServer);
        FHTTPServer := THTTPInstance.Create(FServerInfos.Config.GetPortmORMot, [FServer], '+', useHttpApiRegisteringURI);
      end;

There is were i create all.  FFactory.ConnectionNativeDBFactory.GetMongoDB.GetMongoDB is a Factory that returns for me a TMongoClient, and i  think the rest is self-explain

and this is the Create of the FServer
https://pastebin.com/K3rF0NS0

the SQLModel is this

function DataModel(Root: string): TSQLModel;
begin
  Result := TSQLModel.Create([TSQLAuthGroup, TSQLAuthUser, TSQLTestTable], Root);
end;

Thanks,
Shadownildo

#29 mORMot 1 » Table creation in MongoDB » 2019-05-29 14:13:37

Shadownildo
Replies: 16

Hi There, I'm developing a Multi Database Server, and MongoDB is one of the last guys i need to implement, but i'm having some trouble to Define the SQLRecords Tables in the database,
i already Read the Documentation and search around here and nothing have helped, so i'm making this topic
i have this SQLRecord

  TSQLTestTable = class(TSQLRecord)
  private
    FAge: Integer;
    FName: RawUTF8;
    FAdress: RawUTF8;
  published
    property Name: RawUTF8 read FName write FName;
    property Age: Integer index 4 read FAge write FAge stored AS_UNIQUE;
    property Adress: RawUTF8 index 100 read FAdress write FAdress;
  end;

I'm using StaticMongoDBRegisterAll() to Register all the tables im SQLModel, but the fields are not
persist in the database, Only Age because is Stored AS_UNIQUE, but i need to know if there is a way i can have all the fields in the  Collection, i'm missing something? MongoDB it's not suppose to have all the fields?

#30 Re: mORMot 1 » Maybe a Possible Bug in Unserialization ObjectLoadVariant » 2019-05-03 12:28:37

ab wrote:

I can't follow exactly what you expect.
Class parsing stop at failure, by definition - but it depends on what you call "failure", and there are options to tune the behavior.

Please don't put extensive code in the forum - see https://synopse.info/forum/misc.php?action=rules
One https://en.wikipedia.org/wiki/Minimal_working_example could be more easy to understand.


Thanks for the answer !
Sorry about that Ab, for me it was not a extensive code, i will try to minimize next time. About The Parsing, doing with Datasnap and using TJSON.JsonToObject() for Unserialize, this problem don't occours , but it's much more Slower than the ObjectLoadVariant(), this is why i don't know if was a bug or just the way it has to be.

Sorry about the Bad English.

#31 mORMot 1 » Maybe a Possible Bug in Unserialization ObjectLoadVariant » 2019-05-02 12:44:00

Shadownildo
Replies: 2

I don't know if it's a Bug or if have to be in that way, but making some test Cases, trying to Unserialize a JSON , i found out that if i have some  Sample Objects like those underneath

type
TSampleObject1 = Class(TPersistentWithCustomCreate)
private
FField1 : Integer;
FField2 : Extended;
FField3 : TSampleObject2 ;
FField4 : String ;
procedure SetField4(Value : TSampleObject2);

published
Constructor Create;override;
property Field1 : Integer read FField1 write FField1;
property Field2 : Extended read FField3 write FField3;
property Field3 : TSampleObject2 read Field4 write SetField4;
property Field4 : String read FField2  write FField2 ;
end;

TSampleObject2 = class
private
FField5 : Integer;
FField6 : String;
FField7 : Extended;
public
property Field5 : Integer read FField5 write FField5;
property Field6 : String read FField6 write FField6;
property Field7 : Extended read FField7 write FField7;
end;

If in the Unserialization For some reason the Field3 failed to Parse, (In some Cases this type of Field Sometimes Parse, Sometimes don't) Field3 and Field4 Don't even try to parse, same goes to if The Field3 is not Created, he fail to Parse and Field4 don't even try to parse, i don't know if it's have to be in this way, But if it's really supposed to be , I'll remove the post

#32 Re: mORMot 1 » Service Contract Differs » 2019-01-04 16:04:35

Shadownildo wrote:
ab wrote:

The contract hash differs only if the interface is changed.


But i not change anything in the Service Interface, Not even a Single Line.... What happens is when Release a new Version, both are in the Same "Build", it Works, but when i Maintain the Mega Server version and change Others Units not Correlated with the Service in the Client Server Version, This error Appears...

There is a Way that i can "Ignore" This Contracts?

#33 Re: mORMot 1 » Service Contract Differs » 2019-01-04 16:00:18

ab wrote:

The contract hash differs only if the interface is changed.


But i not change anything in the Service Interface, Not even a Single Line.... What happens is when Release a new Version, both are in the Same "Build", it Works, but when i Maintain the Mega Server version and change Others Units not Correlated with the Service in the Client Server Version, This error Appears...

#34 mORMot 1 » Service Contract Differs » 2019-01-04 15:21:15

Shadownildo
Replies: 4

Hello there, I'm having some trouble with the Services methods and i don't know why, let me explain. I have a Service that do a constantly validation in a Mega Server, and it works when i Release, but when i have some update in the Client Server, the Contracts Differs, even if i don't change nothing in the specific Service, but i Have other Service that works Fine and is Almost the Exact same code... I need some help because i cannot find where i have to make changes, and i already read the documentation and not find anything useful.



unit InterfaceAmbiente;

interface

uses
  mORMot, SynCommons;

type
  IRestAmbiente = interface(IInvokable)
    ['{748BB1BE-0503-408C-B72C-9838CD9F012C}']
    function CaptureAll: RawUTF8;
    function Verify (CNPJCLIENT: RawUtF8): RawUtF8;
    procedure SendingDatabase(ID,IDPessoa: Integer; DataBase: string;
      DatabaseLog: string; Port: string; PortHTTP: string; PortmORMot: string;
      UserName: string; Password: string; Host: string);
  end;

const
  SERVICE_INSTANCE_IMPLEMENTATION = TServiceInstanceImplementation.sicSingle;

implementation

initialization

TInterfaceFactory.RegisterInterfaces([TypeInfo(IRestAmbiente)]);

end.

////// This is the Interface Service that is in Mega and Client Servers and have Contract Differs


procedure TRESTServerSIGEPS.ConfigServices;
var
  ServiceFactoryServer: TServiceFactoryServer;
begin
  ServiceFactoryServer := Self.ServiceDefine(TRestLicenca, [IRestLicenca],
    SERVICE_INSTANCE_IMPLEMENTATION);
  ServiceFactoryServer := Self.ServiceDefine(TRestAmbiente, [IRestAmbiente],
    SERVICE_INSTANCE_IMPLEMENTATION);

  ServiceFactoryServer.SetOptions([], [optErrorOnMissingParam]);
 
end;

///// This is the Service Settings on the Servers

unit InterfaceRestLicenca;

interface

uses
  mORMot, SynCommons;

type
  IRestLicenca = interface(IInvokable)
    ['{A043A8F0-813F-4702-B910-B31BCFEB831E}']
      function GetEncrypted(ACNPJ: RawUTF8): RawUTF8;
  end;

const
  SERVICE_INSTANCE_IMPLEMENTATION = TServiceInstanceImplementation.sicSingle;

implementation

initialization

TInterfaceFactory.RegisterInterfaces([TypeInfo(IRestLicenca)]);

end.

// And this is the Other Service that Validate Login but that not have Contract Issues.


Exception Error
https://imgur.com/FLShFb3

#35 Re: mORMot 1 » UPDATE on TSQLRECORD Field » 2018-10-10 13:35:16

ab wrote:

It is not supported in nested fields IIRC.
You have to update the field itself.
Try

 FmORMot.Update(Ambiente.Version);

We already try this, but in the end, When he updates, in the database he comes empty. We Try every single Command in the Documentation about Update, but don't work.

we already  found one solution but, it's change the TSQLRecord field  to a Integer and Relate the tables in the in the Create, but i don't think this is the best solution.

#36 mORMot 1 » UPDATE on TSQLRECORD Field » 2018-10-10 12:53:31

Shadownildo
Replies: 2

Hello there, i am having a problem in performing the Update command to update the ID of a TSQLRecord field in specific,

this is part of the code
//////////////////////////////////////////////////////////////////////////////////////////////////

  Ambiente := TSQLAmbiente.CreateJoined(FmORMot, ID);
  try
      Ambiente.Database := DataBase;
      Ambiente.DatabaseLOG := DatabaseLog;
      Ambiente.User := UserName;
      Ambiente.Password := Password;
      Ambiente.ServerCharSet := ''
      Ambiente.Sldialect := 3;
      Ambiente.HostName := Host;
      Ambiente.TipoBancoDados := '';
      Ambiente.WaitOnLocks := False;
      Ambiente.Port := Port;
      Ambiente.PortHttp := PortHTTP;
      Ambiente.PortmORMot := PortmORMot;
      Ambiente.Version.IDValue := IDVersion;
      FmORMot.Update(Ambiente);
  except
     raise Exception.Create('Não foi possivel Editar!');
    end;


////////////////////////////////////////////////////////////////
The Update command changes the other fields, but this Version field is a TSQLRECORD, it receives the correct value of the ID, but in Update and Commit, the value saved in the database is a gigantic that does not match the value received.
i Already read all the documentation about Update command and can't found the answer. How i change the TSQLRecord field?

Board footer

Powered by FluxBB