You are not logged in.
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?
The mORMot 1.18 - SynLog.pas
function EventArchiveSynLZ(const aOldLogFileName, aDestinationPath: TFileName): boolean;
no longer available with mORMot2?
Oh Cool. Thank you very much.
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?
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).
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?
I tried <>, !=, but none of them seems to work?
LObjList := RetrieveList<MyObject>('Object_ID <> ?', [AObjectID])
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!
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.
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;
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"?
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:
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?
I want do dump a record into a JSON object, what value should I use for TSQLOccasion, in TSQLRecord.GetJSONValues?
TSQLRecord.GetJSONValues(True, True, ?);
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.
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?
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.
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
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?
Some database have the "partitioning" feature - is this supported in mORMot?
https://dev.mysql.com/doc/refman/8.0/en … oning.html
https://www.postgresql.org/docs/10/ddl- … oning.html