#101 mORMot 1 » Help! mORMot2 migration problem » 2021-05-15 20:53:35

wxinix
Replies: 3

I have a fairly new project in the past month using mORMot 1.18.

I tried to migrated it to mORMot 2, today, following @ab advice.

The code update was pretty smooth, and the code built fine.

Then the exception showed up, when calling TRestServerDB.CreateMissingTables:  Exception class EZSQLException with message 'SQL Error: ERROR:  relation "some_table" already exists
ERROR 42P07relation "some_table" already exists

Shouldn't CreateMissingTables only try to create tables when "missing"?  But it seemed it tried to create existing tables?

What is the catch here?

#102 mORMot 1 » mORMot2, function EventArchiveSynLZ no longer available? » 2021-05-15 18:10:03

wxinix
Replies: 2

The mORMot 1.18 - SynLog.pas 

 function EventArchiveSynLZ(const aOldLogFileName, aDestinationPath: TFileName): boolean;

no longer available with mORMot2?

#104 Re: mORMot 1 » How to save dynamic array to TDocVariant? » 2021-05-15 12:55:11

ab wrote:

You can use a temporary JSON conversion.

For mORMot 2, I have just added some overloaded TDocVariantData.InitArrayFrom() method including a TDynArray version, or an "array of double" input.

Thank you very much.  I am using mORMot 1.18 on a new development (following the advice taht mORMot 2 is still not ready for production).

I am somewhat "concerned" - will mORMot 2 be significantly different?  Once started with mORMot 1.18 for a project, what should I do to maintain  the project in the long run?  Will 1.18 be deprecated once mORMot 2 is stable?

#105 mORMot 1 » How to save dynamic array to TDocVariant? » 2021-05-14 12:04:01

wxinix
Replies: 5

var LData: TArray<Double>;

// LData is a dynamic array; its length is unknown at compile time.

_arr(LData) doesn't work.....

I am doing this because I want to save the array as string in database (not Blob).

#106 Re: mORMot 1 » What is the correct SQLWhere for "Not Equal" condition? » 2021-05-13 12:37:50

Thank you.  It is the mORMot static in memory db (object list).  I checked the manual it seems static in-mem db doesn't support "Not Equal" condition?

#107 mORMot 1 » What is the correct SQLWhere for "Not Equal" condition? » 2021-05-12 23:25:26

wxinix
Replies: 3

I tried <>, !=, but none of them seems to work?

LObjList := RetrieveList<MyObject>('Object_ID <> ?', [AObjectID])

#108 Re: mORMot 1 » BatchSend mistakenly strips off millisecond part of TDateTimeMS » 2021-05-09 11:29:29

ab wrote:

Which provider (SynDB properties class) are you using?

Please try my latest patch on trunk.

I use PostgresSQL. TSQLDBZEOSConnectionProperties

Thank you very much.  The latest patch works!

#109 mORMot 1 » BatchSend mistakenly strips off millisecond part of TDateTimeMS » 2021-05-09 01:36:06

wxinix
Replies: 2

TDateTimeMS type is supposed to have a millisecond part, when adding to an external database (e.g., PostgreSQL).

It works as expected if the record is added individually using the Add method.

Howerver, when BatchAdd, mORMot will mistakenly strip off the millisecond part of TDateTimeMS field inside method TSQLDBStatementWithParams.BindArray, Line 7891-7896, of SynDB.pas:

if (ParamType=ftDate) and (ChangeFirstChar<>'T') then
    for i := 0 to ValuesCount-1 do // fix e.g. for PostgreSQL
      if (p^.VArray[i]<>'') and (p^.VArray[i][1]='''') then begin
        v.From(PUTF8Char(pointer(p^.VArray[i]))+1,length(p^.VArray[i])-2);  // <<---  This line would strip off the millisecond part?
        p^.VArray[i] := v.FullText({expanded=}true,ChangeFirstChar,'''');
      end;

I also checked the mORMot-generated SQL query sent to the database engine, which confirmed the above.

Can you please double check? Thanks.

#110 Re: mORMot 1 » Does mORMot work with FastMM5? » 2021-05-07 19:50:49

ab wrote:

If TestSQL3 is fine, then the problem is in your code.
You are freeing the TSQLModel too soon.

Hello @ab  Many thanks for the confirmation.   You made my day.  Following your hint, I found the issue.  Thanks again!

This issue won't be detected by Delphi's default MM, and only surfaces up with FastMM in FullDebugMode. And the lesson I learned is: If TSQLRestServerDB holds a reference to TSQLModel, then TSQLModel must be free-ed AFTER TSQLRestServerDB.

destructor TMormotDatabase.Destroy;
begin
  FSQLModel.Free; // <-- this TSQLModel is being free-ed BEFORE TSQLRestServerDB.
  FSQLDBConnectionProps.Free;
  FServer.Free; // <-- FastMM5 in FullDebugMode (and ONLY FullDebugMode) will detect access violation to an already free-ed TSQLModel.

  inherited;
end;

#111 Re: mORMot 1 » Does mORMot work with FastMM5? » 2021-05-07 15:24:31

ab wrote:

Check if the Access Violation comes from mORMot code, or not from your code.
The regression tests (TestSQL3.dpr) should run with no memory leak.

A minimal reproducible example may help.

I checked TestSQL3.dpr with FastMM5, with FullDebugMode = ON,  and everything is fine (as always with mORMot!)

Then I found out all of the access-violation comes from this code:

function TSQLModel.SafeRoot: RawUTF8;
begin
  if self=nil then
    result := '' else
    result := fRoot;  // <----------------  access violation happens here, as reported by FastMM5, as "invalid Read of address 80808078".
end;

From FastMM5 manual, it says: "In debug mode freed memory blocks will be filled with the byte pattern  $808080... so that usage of a freed memory block or object, as well as corruption of the block header and/or footer will likely be detected."

So my guess is, fRoot in the above code is already freed, and filled with $80808078.  Then the line result := fRoot will trigger FastMM5 report access violation.

@ab - what do you think and advise for this situation?  I guess I'll just turn off "FullDebugMode"?

#112 Re: mORMot 1 » Does mORMot work with FastMM5? » 2021-05-07 13:01:06

I use Delphi 10.4.2

I'd like to be consistent with mORMot.  So I'll forget about FastMM5, and use mORMot's version of FastMM4, but mORMot's FastMM4 doesn't seem to catch a very simple memory leak?  Does it require FullDebugMode.dll?  What is the correct way to use mORMot's FastMM4 (for better performance and memory safety)?


program Project1;

uses
  FastMM4 in 'FastMM4.pas', // mORMot's version of FastMM4
  Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  ReportMemoryLeaksOnShutDown := True;
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

procedure TForm1.FormCreate(Sender: TObject);
begin
  var LLeakedObject := TObject.Create;
end;

Here is the small project:

#113 mORMot 1 » Does mORMot work with FastMM5? » 2021-05-07 03:48:53

wxinix
Replies: 7

I am using mORMot 1.18 latest.

I found if I include FastMM5, while turn on the "full debug mode" - then my mORMot application throws all weird access violation errors.  However, if "full debug mode" is off, while only including FastMM5 in the project, there is not access violations.

Any one has encountered the same? Any advice?

#114 mORMot 1 » What value should I use for TSQLOccasion? » 2021-04-28 03:34:37

wxinix
Replies: 1

I want do dump a record into a JSON object, what value should I use for TSQLOccasion, in TSQLRecord.GetJSONValues?

TSQLRecord.GetJSONValues(True, True, ?);

#115 Re: mORMot 1 » What is the difference between TSQLRestClientDB, and its server? » 2021-04-14 15:20:57

turkerali wrote:

Dear @wxinix,

You may have issues if you intend to cache external database tables.
Please check this post for ab's clarifications regarding caching.

Regards.

Thank you very much for the kind reminder.

#116 Re: mORMot 1 » What is the difference between TSQLRestClientDB, and its server? » 2021-04-14 12:21:08

turkerali wrote:

A similar question was asked before. Please check this link.

@turkerali

Thank you very much for the heads-up.

I also found the reason why
TSQLRestClientDB.Delete(TMySQLRecord, '') cannot empty the whole table.   The empty SQLWhere cannot be translated to a valid restful DELETE URI.

@ab
So, for best client-server (e.g., postgreSQL server) ORM performance, I should use TSQLRestClientDB.Server to do the Add/Delete/Retrieve/Update?  Or should I use TSQLRestClientDB, for its caching?

Thank you again.

#117 mORMot 1 » What is the difference between TSQLRestClientDB, and its server? » 2021-04-14 01:48:12

wxinix
Replies: 5

What is the difference of

TSQLRestClientDB.Add/Delete/Retrieve

versus

TSQLRestClientDB.Server.Add/Delete/Retrieve?


Also I found
TSQLRestClientDB.Delete(TMySQLRecord, '') doesn't empty the table, while TSQLRestClientDB.Server.Delete(TMySQLRecord, '') empty the table.  Why so?

#118 Re: mORMot 1 » new book about mORMot » 2021-03-31 12:30:10

flydev wrote:

Just a small question to be sure, as the last post here is from 2017, the EWB book 2nd edition is about mORMot too, right ?

I purchased that book. And I regret big time.

Though it is appreciated that this might be the only published mORMot book on the market, and the table of contents appear very logical and reasonable,  yet the book contents are full of typos, incomplete samples, misleading and incorrect information, and confusing lines out of context!!   The misleading/incorrect information will do you big harm! 

I strongly suggest the author to carefully proofread the book, and fix the typos and correct the wrong information.

Also it claimed to have been proofread by AB - I don't know how he did the "proofread" but the book is of very low publishing quality, I am very upset with the purchase.  This forum and SAD are probably more useful.

#119 Re: mORMot 1 » how do mormot groups query criterias » 2021-03-30 23:10:26

OK. I found the answer from this post:
https://synopse.info/forum/viewtopic.php?id=4986

OneFieldValue, and use 'SUM(xx)' as the field name

#120 Re: mORMot 1 » how do mormot groups query criterias » 2021-03-30 22:05:45

ab wrote:

The WHERE clause is sent to the SQL backend untouched, so you can do whatever the backend knows.
So both your clauses would be possible with mORMot with a SQL backend (like SQlite3 or any SynDB external variant).

Some restrictions apply to supported NoSQL engines, thought:
- the internal in-memory noSQL engine (e.g. TSQLRestServerFullMemory) has a limited WHERE clause ability, with only a single conditional.
- MongoDB SQL to pipeline conversion is more complete: you can use several AND/OR clauses with no problem, but parenthesis support is not done.

This is great to know.

Then how can I perform something like SELECT AVG(Speed) ...WHERE.... GROUP BY xxx? Is it doable with mORMot?

Board footer

Powered by FluxBB