#1 Re: mORMot Framework » Enhanced URI routing for method-based services » 2022-05-14 12:29:01

edwinsn wrote:

If what you are proposing is possible with mORMot, when we can write a 'load balancer' with mORMot? big_smile

Yes why not  big_smile
THttpGatewayServer as descended, with methods or interface for remote AddRoute, DeleteRoute
In case of

HttpServer.AddRoute('$/$/overview', 'http://dynamicserver1.net/restroot/overview?lng=$&product=$');
HttpServer.AddRoute('$/$/overview', 'http://dynamicserver2.net/restroot/overview?lng=$&product=$');
HttpServer.AddRoute('$/$/overview', 'http://dynamicserver3.net/restroot/overview?lng=$&product=$');

you will have load balancer big_smile
Very useful in case of bugfix update/release, Just run new bugfix server and shutdown buggy server
Or dynamically update version, if you running AddRoute('/api/v1/func1...')
Just run new release with AddRoute('/api/v2/func1...'), update all clients to v2 and shutdown v1 server
Nice feature will be integrated MVC admin panel where you can monitor and dynamically add or delete working servers

THttpGatewayClientServer(THttpServer)
Just configure GW URI and server will register/AddRoute  all routes on start. On shutdown DeleteRoutes.
Shutdown can be invoked remotely by GW Server

Only sky is the limit big_smile

#2 Re: mORMot Framework » Enhanced URI routing for method-based services » 2022-05-13 22:11:11

@ab,
Excellent idea, it make sense to me for MVC application where user see URL.

Another idea

HttpServer.Route('$/$/overview', 'http://dynamicserver1.net/restroot/overview?lng=$&product=$');

Converting httpserver to proxy/gateway where dynamicserver1.net can dynamically add route to httpserver on start.
I know this is more complex change. Just idea.

#3 Re: mORMot Framework » MVC URI routing » 2022-05-11 09:32:17

Not possible in interface based service.
Workaround will be to create method based service, manually parse URI after root and call interface in method implementation.

#4 Re: mORMot Framework » Benchmark PostgreSQL, SQLite and mORMot » 2022-05-07 18:28:32

@tihory, I play with your gist bench, add SQLite3 and FirebirdSQL server and BatchAdd in client.

SQLite3 DB ORM :	Records Per Second : 17623
SQLite3 DB ORM :	Batch Records Per Second : 509113
PostgreSQL DB ORM :	Records Per Second : 1295
PostgreSQL DB ORM :	Batch Records Per Second : 108610
FirebirdSQL DB ORM :	Records Per Second : 2605
FirebirdSQL DB ORM :	Batch Records Per Second : 37846

This is localhost test on my 3-4 year old laptop with i3-8145U with 2 cores 4 HT.
On server you can play with PQ and FB defines
On client you have BatchAdd define to switch client mode
With your hardware you can expect much better req/sec
Batch Inserts is not a silver bullet for every case/project.
Without Batch all clients sends 1000 http req. and most of the time is spent in http parsing, object serialization/deserialization, ORM mapping and small time in real DB insert.
http and ORM have some overhead in this test, but this is much closer to real server app.
My changes in gist https://gist.github.com/TTomas/619173ca … 3c9c290cd7

#6 Re: mORMot Framework » Benchmark PostgreSQL, SQLite and mORMot » 2022-05-04 19:07:16

@tihory you don't publish results row/sec
With small changes you can change PQ to SQLite3 ORM to compare results.
You don't stress database enough with this micro bench. You see only 1-2 connections with insert in a time.
Try to increase client threads to some real numbers ex.100. Try with 10 worker threads and 100 clients threads.
It will be nice if you have 1 client server, 1 app server and 1 PQ server in LAN, real HW servers.
You can add in Client

    writeln('Start Client: ', Index); //Add
    for I := Index * PerConnection to (Index + 1) * PerConnection - 1 do
    begin
      Http.Add(Texts[I], True);
    end;
    writeln('End Client: ', Index);  //Add

Just to check that all clients run in parallel.

Edited
Try to create separate client and server bench application. Too many threads in 1 process will stress memory manager.

#7 Re: mORMot Framework » Benchmark PostgreSQL, SQLite and mORMot » 2022-05-03 13:11:13

@tihory, your test benchmark is not complete. You don't test PQ ORM multithreaded inserts. Try to add http server in test TRestHttpServer. TRestHttpServer.Create have aThreadPoolCount param default to 32 worker threads with own PQ connection pool.
After PQProps := TSqlDBPostgresConnectionProperties.Create('127.0.0.1', 'mormot_postgres_test', 'root', '1');
Set
PQProps.ThreadingMode := tmThreadPool;
If you use
PQProps.ThreadingMode := tmMainConnection;
you will have only 1 db connection and 32 working threads will use this one connection with Lock/UnLock.
You will need multiple TRestHttpClient's in multiple threads for test.

#8 Re: mORMot Framework » TSimpleHttpClient extra CRLF before data » 2022-05-01 11:17:26

Thanks @ab. Yes, problem is in my code in my descended class I use TStringList to AddHeaders and send StringList.Text as Header.
Have a nice holiday

#9 mORMot Framework » TSimpleHttpClient extra CRLF before data » 2022-04-29 22:25:10

ttomas
Replies: 2

Hi @ab, can you check line 1505/1508 in mormot.net.client.pas
I solve my problem with  SockSend(ctxt.header) ->  SockSend(ctxt.header, True)
Making simple POST request with data '1234', client receive #10#13'12'. '34' is also send but Content length is 4
Monitoring with wireshark I notice extra CRLF before data.

Hypertext Transfer Protocol
    POST /api/v3/pin HTTP/1.1\r\n
    Host: 10.0.12.108:8086\r\n
    Accept: */*\r\n
    User-Agent: Mozilla/5.0 (Win; mORMot 2.0.1 HCS)\r\n
    Content-Length: 4\r\n
    Accept: application/json\r\n
    Content-Type: application/json\r\n
    \r\n
    [Full request URI: http://10.0.12.108:8086/api/v3/pin]
    [HTTP request 1/1]
    [Response in frame: 32]
    File Data: 4 bytes
JavaScript Object Notation: application/json
Line-based text data: application/json (2 lines)
    \r\n
    12

#10 Re: mORMot Framework » Firebird transactions » 2022-02-22 11:23:52

@ab
In test.core.crypt.pas check line 2299 and 2301
Check(st2.Revoke(c3.GetSerial...
I change to
Check(st2.Revoke(c3, ...
to compile test

#11 Re: mORMot Framework » mORMot 2 ORM Performance » 2022-02-22 10:38:44

nomorelogic wrote:

Lazarus 2.2
FPC 3.2.3
Firebird 3.0.7.33374

Can you try with Laz 2.0.12 and Fpc 3.2 as recommended version and trunk version of mormot2

nomorelogic wrote:

do I need any compiler directive to compile Zeos?

No, I just install Zeos from Online package manager, open mormot2 package in custom options uncheck NOSYNDBZEOS, add zdbc as required package, add include path for zeos.inc and recompile mormot2 package.

nomorelogic wrote:

did you try firebird embedded or via network (like my test)?

I try with network localhost:3040, Fb4 version is set to 3040 port.
Do you have test database created before test. I think Zeos only create db file in embedded mode. In network mode you must create database before test.
Also check db file owner, must be firebird:firebird. If you create db in embedded mode owner will be current user.

#12 Re: mORMot Framework » Firebird transactions » 2022-02-22 10:08:41

Yes for Fb4 Ibx is 20-30% faster, for Fb3 10-20% slower. Zeos have better optimized parameters setting. I try low level direct buffer setting for integer, currency and utf8 string and performance is same, but remove that code and keep fbintf param setting for safety and type conversion.

#13 Re: mORMot Framework » mORMot 2 ORM Performance » 2022-02-22 01:05:48

Firebird and FPC/Lazarus version?
Can't confirm on Win32/64, Fb3, Fb4, Lazarus 2.0.12. FPC 3.2.2, same Zoes 7.2.14
All tests pass (Zeos and Ibx).
You can also try IBX driver, I just push new commit with IBatch interface use for Fb4
https://github.com/TTomas/mORMot2/blob/ … ql.ibx.pas

#14 Re: mORMot Framework » Firebird transactions » 2022-02-21 23:59:11

I create new pull request https://github.com/synopse/mORMot2/pull/75
With Firebird v4 batch Insert and Update use new IBatch interface. Using IBatch interface double insert performance.

Insertion speed (rows/second)
Firebird 4 using execute block for batch Insert
              Direct      Batch       Trans       Batch Trans
Ibx firebird  1745        22317       2946        22017

Firebird 4 using IBatch interface
              Direct      Batch       Trans       Batch Trans
Ibx firebird  1726        46499       6309        46763

#15 Re: mORMot Framework » mORMot 2 ORM Performance » 2022-02-21 21:32:33

You don't need to set cFIREBIRDEMBEDDEDDLL = '' if you have only one instance/version of firebirdsql
You run test in non embedded mode, cFirebirdServerZeos = '127.0.0.1';
In this case multithreaded connection pool is created and drop table will fail in firebird if you have active connection to db.
RunWrites(trans, batch) is called 4 times in test. First run will pass, but  second can fail if you have active connection to db.
You can see code in procedure TTestDatabaseExternalAbstract.ClientCreate;  line 765
Try to change line 385 in procedure TTestFirebird.ZeosFirebird; to  Flags := [dbPropUntouched];
Test 4 times drop table and insert 10000 rows. With this changes your test will only insert rows.
You can also uncomment lines 386,387 to delete db file on start. You will need firebird user permission to delete file.

You can also try to change threadingMode of ConnectionProperties to tmMainConnection

#16 Re: mORMot Framework » MVCApplication add Response Header » 2022-01-08 18:40:23

Thanks @ab, this will solve the problem.
Can you please at line 1740 add

    if head<>'' then
      fOutput.Header := fOutput.Header + #13#10 + head;

In case when CustomOutHttpHeader := '' mvc application raise exception:
{ "errorCode":500, "errorText":"Unsafe HTTP header rejected [Content-Type: text/html; charset=UTF-8$0d$0a$0d$0aETag: \"57A6E6D8\"]" }
In same method depend of business logic I insert none, one or many response headers.

#17 mORMot Framework » MVCApplication add Response Header » 2022-01-08 12:42:23

ttomas
Replies: 3

Any hint how to add Response Header from MVCApplication.

    context := ServiceRunningContext;
    context.Request.Call^.OutHead := context.Request.Call^.OutHead + #13#10 + 'Test: test';

Trying this code from MVCApplication method, mORMot2/FPC, don't return Test Header.
I'm playing with htmx for client side (htmx.org) and need to trigger some events on client with response header.
https://htmx.org/docs/#requests
I need to send response header from mvc controller depending of business logic in mvc method.

#18 Re: mORMot Framework » Multi-threaded BatchAdd performance » 2021-09-29 23:51:05

In my pull request https://github.com/synopse/mORMot2/pull/58
I convert sample 15 and results are:
Running tests using Synopse mORMot framework 2.0.1, compiled with Free Pascal 3.2 64 bit, against SQLite 3.36.0, on Manjaro Linux - Linux 5.4.148-1-MANJARO, at 2021-09-30 01:44:36.

Insertion speed (rows/second)
                              Direct      Batch       Trans       Batch Trans
Sqlite file full              304         15413       29067       82673
Sqlite file off               4027        69256       35187       90535
Sqlite file off exc           12478       82022       35143       90420
Sqlite file off exc aes       8005        73736       35028       88832
Sqlite in memory              28583       90438       35340       91195
In memory static              82611       183708      85679       183769
In memory virtual             80202       170404      84334       170010
External sqlite file full     305         7638        31593       99072
External sqlite file off      5352        67390       39135       106364
External sqlite file off exc  17633       92354       38797       105929
External sqlite in memory     32937       107940      38307       106935
Remote sqlite socket          5587        49019       5781        42242

Read speed (rows/second)
                              By one      All Virtual All Direct
Sqlite file full              24912       281563      275360
Sqlite file off               25301       289184      290528
Sqlite file off exc           42320       292620      293083
Sqlite file off exc aes       42133       296155      298169
Sqlite in memory              42353       289502      300300
In memory static              91441       551876      554692
In memory virtual             90920       211855      212539
External sqlite file full     50652       130589      286057
External sqlite file off      50972       131665      286368
External sqlite file off exc  51019       131585      286763
External sqlite in memory     49759       130938      286944
Remote sqlite socket          6518        117181      227489

#19 Re: mORMot Framework » Firebird transactions » 2021-09-27 14:22:37

ab wrote:

But you have closed the pull request.
Is it on purpose?

Sorry not much experience with github. I add 1 more commit, move type out of class declaration and yes I close, can I reopen pull request or need to create new? Not on purpose :-)
I create new pull request https://github.com/synopse/mORMot2/pull/58
Please ignore #57

#20 Re: mORMot Framework » Firebird transactions » 2021-09-26 23:43:11

I just pull request https://github.com/synopse/mORMot2/pull/57
Included conversion of sample 15 and this is results:
Running tests using Synopse mORMot framework 2.0.1, compiled with Free Pascal 3.2 64 bit, against SQLite 3.36.0, on Windows 10 64bit (6.2.9200), at 2021-09-26 21:29:48.

Insertion speed (rows/second)
                              Direct      Batch       Trans       Batch Trans
Ibx firebird                  3128        39378       22353       41027
Zeos firebird                 3035        39629       24809       38625

Read speed (rows/second)
                              By one      All Virtual All Direct
Ibx firebird                  12283       122989      179513
Zeos firebird                 30407       162522      209178

Expected result for Read speed-By one (this is read of 5000 records one by one with start/read/commit transaction in Ibx, in this test Zeos never Commit or CommitRetaining transaction)

@EgonHugeist
I test with Zeos 7.2-patches.
8.0-patches have a problem with Batch inserts. Data is corrupted in table after batch inserts, also a lot of records are missing (not 5000 records after Batch). I try with and without MORMOT2 define, same problem.
Tested with Firebird 3.0.7 in embedded mode
i7-4700MQCPU

Same test on i3-8145U
Running tests using Synopse mORMot framework 2.0.1, compiled with Free Pascal 3.2 64 bit, against SQLite 3.36.0, on Manjaro Linux - Linux 5.4.148-1-MANJARO, at 2021-09-25 19:18:03.

Insertion speed (rows/second)
               Direct      Batch       Trans       Batch Trans
Ibx firebird   1549        12895       3170        13066
Zeos firebird  1925        15533       2119        16242

Read speed (rows/second)
               By one      All Virtual All Direct
Ibx firebird   1663        42024       71331
Zeos firebird  1954        72547       96491

#21 Re: mORMot Framework » Firebird transactions » 2021-09-15 00:03:49

Sorry for delay, busy day.
I send pull request with some bugfix and added Zeos and Ibx project files for mvc-blog example.
https://github.com/synopse/mORMot2/pull … 4015d14588
Main goal with mvc-blog sample is OK. Server create 32 thread pull connections after many hits,  and zero (0) active transactions on idle, Zeos always keep 32+ started transactions.
Monitored with
select * from [MON$ATTACHMENTS, MON$TRANSACTIONS, MON$STATEMENTS]
This query's are really nice to find forgotten statement/cursor/transaction, usually by missing ReleaseRows in code like:
if step then
   DoSomething();
// missing ReleaseRows

I test with code from test.orm.extdb.pas, USEZEOS define part, all pass.
Tested only on Windows with Fpc and Firebird 3, for now. Delphi users welcome to test, fbintf can be installed on D2010>=

This is numbers of 5 tests, Batch add/receive of 1111 rows.
https://gist.github.com/TTomas/b77f951b … 2ae5f29adc
Only interesting is Test1 (BatchAdd of 1111 records), Zeos is really fast, thanks to @EgonHugeist.
Need some testing to tune number of statements in execute block.
I'm planning to implement new Firebird4 IBatch interface also
Test2 is expected to be slower 1111 Retrieve, because Ibx driver for every statement (1111) StartTransaction, Execute and Commit,
Zeos only Execute statement, monitoring this with trace and audit on Firebird server.
Second Ibx test is with ZEOSTRANS define to simulate same behavior.

Real Performance 15-Samples is in ToDo list

#22 Re: mORMot Framework » Firebird transactions » 2021-09-14 00:38:36

Inspired by transaction handling of ZeosLib and Firebird by this topic
  and goal to have zero started transaction on Firebird server when nobody is connected
  I create this mORMot2 database connection for FirebirdSQL.

  For low level connection I use MWA Software Firebird Pascal API package (fbintf),
  part of IBX for Lazarus.
  More details on https://www.mwasoftware.co.uk/fb-pascal-api

  - With explicit StartTransaction (Batch) all statements in connection
    is executed with this main transaction owned by connection.
  - If no explicit StartTransaction is called, all statements create internal transaction
    on prepare and COMMIT after execution or Eof or ReleseRows. This is sotware simulated auto commit.
    This internal transaction is owned by Statement.
  - TSqlDBIbxConnectionProperties.CreateDescendingPK if set to True (Default is False)
    will create only one descending PK index using statement
      PRIMARY KEY(ID) using desc index PK_TableName
    default dFirebird create two indexes on ID, one ascending, second descending
    nedded for select max(ID)
    see http://www.firebirdfaq.org/faq205

    @ab
    This feature need some change in mormot.orm.sql.pas at line 1883
    For testing in my code i now have this improvisation, I change fEngineName when set this property :-)
      dFirebird:
        // see http://www.firebirdfaq.org/faq205
        if fProperties.Engine='IBX1' then
        begin
          result := true;
          exit;
        end
        else
          Descending := true;

  - Batch implemented for insert,update,delete using execute block
  - ToDo Firebird4 API interface have new IBatch interface for insert/update
    also implemented in fbintf package.
  - You must patch FB30Statement.pas and FB25Statement.pas of fbintf, I'm waiting
    for response of MWA Software. fbintf raise exception if Execute is executed
    with different transaction then Prepare transaction.
    Just comment this lines in InternalExecute and InternalOpenCursor and rebuild package.
    more details on https://forum.lazarus.freepascal.org/in … 267.0.html

Source code mormot.db.sql.ibx.pas: https://gist.github.com/TTomas/2cb88c1c … a98f17a5b1

#24 mORMot Framework » Small bug fix in mormot2 » 2021-09-12 15:37:16

ttomas
Replies: 1

@ab in mormot.db.sql.pas, function TSqlDBConnection.GetServerDateTime: TDateTime;
line 6700 ReleseRows is missing

        if Step then
          fServerTimestampOffset := ColumnDateTime(0) - Current;
        ReleaseRows;

I notice this not release statement in Zeos Firebird "select current_timestamp from rdb$database" and keep open transaction/statement.

#26 Re: mORMot Framework » Oracle OCI ARMv8.2 VM » 2021-08-03 12:04:25

After boot of VM you need this commands:
sudo apt update
sudo apt upgrade
sudo apt install lxde
sudo apt install xrdp

sudo passwd ubuntu
# you will add pw for gui login to default ubuntu user

# Lazarus dependency
sudo apt install make binutils build-essential gdb subversion zip unzip libx11-dev libgtk2.0-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev

wget fpcupdeluxe aarch64 and be happy

Yes rdp tcp port 3389 is not public I use ssh port forwarding to my PC
Linux: ssh -L 3389:localhost:3389 -i mykey ubuntu@myip
Windows: Configure Putty-Connection.SSH.Tunnels
You can publish any port in OCI config and Ubuntu FW, not recommended for rdp :-)

#27 Re: mORMot Framework » Oracle OCI ARMv8.2 VM » 2021-08-03 08:48:55

1€ only for verification, try several times. I see this problem on some youtube video.
Try Netherlands as home

#28 mORMot Framework » Oracle OCI ARMv8.2 VM » 2021-08-02 22:59:15

ttomas
Replies: 22

Just open account on Oracle Cloud and create new compute VM: 4 ARMv8.2 CPU 3GHz, 24GB Ram (yes 24GB).
This is always free VM (you can combine this 4 cores and 24GB Ram to 1 or many (4) VM).
Install Ubuntu 20.04 server, then install LXDE and XRdp for remote access.
Now I have nice speed workstation. Install fpcupdeluxe then fpc 3.2.2/laz 2.0.12, all OK. fpcup build is faster then my local pc build :-)
mormot2 compile package OK, build mormot2_test OK.
mormot2test freeze on  2.7. Client server access: , I must press ^C
log end screen stdout: http://halkyon.com/download/mormot2test.zip

This OCI VM can be great mormot application server for some projects. I don't have any connection to Oracle just test there product.

#29 Free Pascal Compiler » Lazarus custom options » 2021-07-27 14:17:14

ttomas
Replies: 1

This is Lazarus bug! Any hint how to set custom defines in mormot2test project in Lazarus/Windows.
When I click on Defines in Custom Options I have error:
Error parsing custom options: Option 11047 is not found in set -v
Try with Lazarus v2.0.12 and v2.0.13 (Laz2fix)
I need to define USEZEOS and add USEIBX, I'm working on FirebirdSQL external connection based on Lazarus IBX2 (FB Pascal API interface) mormot.db.sql.ibx.pas
http://halkyon.com/download/lazerr.jpg

#30 Re: Free Pascal Compiler » mORMot2 (Latest Release) regression test on Win64 failed. Critical? » 2021-07-12 10:58:33

Better to report Issue in quickjs repo.
If you add setlocale(LC_ALL, 'C') this will impact every app using mORMot2 or can be set only for quickjs?

OK I see you edit post, SetLibcNumericLocale is nice workaround.

#31 Re: Free Pascal Compiler » mORMot2 (Latest Release) regression test on Win64 failed. Critical? » 2021-07-11 16:27:39

My locale.conf is:
LANG=en_US.UTF-8
LC_NUMERIC=mk_MK.UTF-8
LC_TIME=mk_MK.UTF-8
LC_PAPER=mk_MK.UTF-8
LC_NAME=mk_MK.UTF-8
LC_ADDRESS=mk_MK.UTF-8
LC_TELEPHONE=mk_MK.UTF-8
LC_MEASUREMENT=mk_MK.UTF-8
LC_IDENTIFICATION=mk_MK.UTF-8

English language with locale formatings only. With this config I have 1000 fails 777<>777.777
When I change locales for numbers line LC_NUMERIC= is missing from locale.conf

 3.1. Core script: 
  - Quick JS low level: 40,057 assertions passed  1.10s
  Total failed: 0 / 40,057  - Core script PASSED  1.10s

Try with
LANG=de_DE.UTF8
LC_NUMERIC=en_US.UTF-8

#32 Re: Free Pascal Compiler » mORMot2 (Latest Release) regression test on Win64 failed. Critical? » 2021-07-11 16:10:21

It's strange I know, 777 come from quickjs, after change locale test fails, but after linux restart test is OK. Try reboot.
I return locale for numbers to my country and test fail again after reboot. Look like quickjs use locale internally for some conversions!

#33 Re: Free Pascal Compiler » mORMot2 (Latest Release) regression test on Win64 failed. Critical? » 2021-07-11 12:50:19

@ab @stj, about 777.777, I have the same error, this is not cpu related only Locales settings, I change in Manjaro Settings Manager - Locale Settings change settings for Numbers and Currency to en_US and test pass no more 777<>777.777. How many times we will have problem with decimal dot or comma, my country locale is decimal comma :-)
Check your /etc/locale.conf

#34 Re: mORMot Framework » mORMot 2 in Good Shape » 2021-07-09 23:44:59

@damiand, I have the same debugger error when try to debug MVC Blog demo with mORMot2.
In Lazarus menu Tools-Options in Debugger-General options try to change InternalStartBreak to gdsbMain.

#35 Re: mORMot Framework » MVC Sample for mORMot2 » 2021-07-08 10:31:24

@ab Thanks and Thanks for adding OnBeforeRender in MVC it will help a lot when using htmx, hotwire turbo or similar libraries where we need to  serve different html response depend of request headers.

#36 Re: mORMot Framework » MVC Sample for mORMot2 » 2021-07-07 19:13:37

@ab this simple test project work in mORMot1 but in mORMot2 raise exception

  aModel := CreateModel;
  try
    aServer := TRestServerDB.Create(aModel,Executable.ProgramFilePath+'MVCServer.db');
    try
      aServer.DB.Synchronous := smNormal;
      aServer.DB.LockingMode := lmExclusive;
      aServer.Server.CreateMissingTables;
      try
        Article := TOrmArticle.Create;
        try
          if aServer.Orm.Retrieve(666,Article) then begin
             writeln(article.GetJsonValues(true,true,ooSelect)); // This is OK Author: 1
             writeln(FormatUTF8('%', [ObjectToJson(Article)]));  // exception
          end;
        finally
          Article.Free;
        end;
        readln;
    finally
      aServer.Free;
    end;
  finally
    aModel.Free;
  end;

#37 Re: mORMot Framework » MVC Sample for mORMot2 » 2021-07-07 11:50:23

Can someone check what is a problem with serialization of TOrmArticle, problem is in procedure _JS_ID serialization of ID.
I create new test simple rest server project to exclude MVCApp, using same sqlite db and MVCModel, same problem.
TOrmArticle use FTS, I create new class TOrmArttest same as TOrmArticle (copy/paste) without FTS, same problem.
I try to change TOrmArttest = class(TOrmContent) to TOrmArttest = class(TOrm) and add all published property from inherited classes, same problem.

I'm experimenting with htmx.org, alpinejs, windi, vite project served by MVC mORMot and want to use mORMot2, some changes must be done in MCV App for serving htmx request, every URI must have 2 mustache templates, 1 for htmx request (HX-data in header of request) only returning iframe/partial and 2 for page reload/refresh full page as now.

#38 Re: mORMot Framework » MVC Sample for mORMot2 » 2021-06-26 10:10:13

Thanks, just to notice TOrmArticle serialization this is not MVC related
  RestModel.Orm.Retrieve(ID,Article);
  writeln(FormatUTF8('%', [ObjectToJson(Article)]));   // << is broken, test in ArticleView

#39 mORMot Framework » MVC Sample for mORMot2 » 2021-06-25 10:11:00

ttomas
Replies: 9

I'm testing mormot2 with FPC Win and Linux and convert 30-MVC Server sample to PUREMORMOT2
You can download converted sample from http://halkyon.com/download/MVCServer.zip
In MVCViewModel.pas
1. Default URI is OK
2. AuthorView is broken with "out Author: TOrmAuthor" parameter, I changed to "var Author: TOrmAuthor" and now is OK (line 42)
3. ArticleView is broken, exception on TObjectList parameter create in ExecuteJson.
In mormot.core.json.pas line 9203, function _New_ObjectList(Rtti: TRttiCustom): pointer;
I change
result := TObjectList(Rtti.ValueClass).Create;
to
result := Rtti.ValueClass.Create;
Now TObjectList is created and ArticleView method is executed, but new exception is raised on serialization of var Article: TOrmArticle in mormot.core.json
line 4966 in procedure _JS_ID
  Ctxt.W.Add(Data^); here Data heve value of $09, Can not access memory at address $09.

#40 Re: mORMot Framework » Possible field mapping error in TSQLRecordPropertiesMapping.Init » 2021-03-31 11:15:17

Is this typo in post or in your code
.MapField('TypeKW', 'Type')
vs
.MapField('Type', 'TypeKW')

#41 Re: mORMot Framework » SynProtoRelay behind Nginx proxy » 2020-10-08 20:26:45

Thank's a lot @ab for your response and this wonderful framework. My confusion is I don' see any Uri from PrivateRaley or PublicRaley to proxy, only address and port. Nginx now proxy / to node vue application, /api to mORMot method based service, /intf to mORMot interface service and I need ex. /relay to PublicRelay server. I already see https://synopse.info/forum/viewtopic.ph … 669#p27669

Where can I post Case Study made by mORMot project's?

#42 Re: mORMot Framework » SynProtoRelay behind Nginx proxy » 2020-10-08 16:09:12

Any sample of nginx conf for private relay as client, what uri/location to proxy. I already serv / and some other uri's.

#43 mORMot Framework » SynProtoRelay behind Nginx proxy » 2020-10-08 12:16:25

ttomas
Replies: 4

Can I put Public Relay (TPublicRelay) behind Nginx proxy server and how to configure nginx?
In TPublicRelay.Create I see aClientsPort and aServerPort. aServerPort is port where TPrivateRelay connect, correct?
Can this be configured if only 443 port is enabled in nginx or I need additional port on nginx?
My idea is to enable on my public web server microservice to connect to private microservice and don't open additional port on web server. Only to open Nginx port to public on web server. In case of Public Relay and client on same web server, I don't need aClientsPort in nginx configuration. What uri to configure in nginx/proxy_pass for PrivateRelay to connect?

@ab waiting for 38 - WebSockets Relay Sample :-)

#44 Re: Free Pascal Compiler » Using Lazarus DBGrid with mORMot. » 2020-08-11 08:31:55

Bsaidus wrote:

hello.
Could you provide a unit complete source code for this.
I Urge to use it in my lazarus project.

Already merged in trunk https://github.com/synopse/mORMot/pull/327
This is my code how I open/create TBufDataset

function TDBConn.OpenAttOpt(aId: integer): TBufDataset;
var Stmt: ISQLDBRows;
begin
  Stmt := fProps.Execute('SELECT ID_ATT, WWVALUE, LABEL '+
     'FROM WWATT_OPT '+
     'WHERE ID_ATT=? ORDER BY ID_ATT, WWVALUE', [aID]);
  if not Assigned(fAttOptDataSet) then begin
     fAttOptDataSet := TBufDataset.Create(nil);
     fAttOptDataSet.FieldDefs.Add('ID_ATT',ftInteger);
     fAttOptDataSet.FieldDefs.Add('WWVALUE',ftString, 25);
     fAttOptDataSet.FieldDefs.Add('LABEL',ftString, 40);
     fAttOptDataSet.CreateDataSet;
     fAttOptDataSet.Fields[0].Visible:=False;
     fAttOptDataSet.Fields[1].DisplayLabel:='Value';
     fAttOptDataSet.Fields[1].DisplayWidth:=25;
     fAttOptDataSet.Fields[2].DisplayLabel:='Label';
     fAttOptDataSet.Fields[2].DisplayWidth:=40;
  end;
  if ToClientDataSet(fAttOptDataSet, Stmt.Instance, 0, cdsReplace, false) then 
     result := fAttOptDataSet
  else
     result := nil;
end; 

Note: If SQL is empty autocreated fields is Bad, I always create fields manually

#45 Re: mORMot Framework » FTS5 content table bug » 2020-06-24 22:42:19

Done
https://github.com/synopse/mORMot/pull/327

Also added changes in SynDBVCL, SynDBMidas for use FPC TBufDataset. Current units don't compile in FPC.With this changes I can use SynDB, SynDBRemote to TBufDataset in FPC.

#46 Re: Free Pascal Compiler » Using Lazarus DBGrid with mORMot. » 2020-06-11 23:31:55

@ab
I just investigate SynDBMidasVCL and find a bug for fpc to work.
{$endif FPC} in line 193 must be moved to line 226. First 3 ToClientDataSet functions are Delphi midas dependent. Also exclude add {$ifndef fpc} in implementation for first 3. Last 2 functions works fine with fpc and TBufDataset.

#47 Re: Free Pascal Compiler » Using Lazarus DBGrid with mORMot. » 2020-06-11 21:42:35

AOG wrote:

Is the above not suitable ?

Not suitable this time. TSQLProject is TSQLRecord descendant, I don't use ORM in this db, it is existing ERP database. I use TSQLDBServerSockets from SynDBRemote on server side and TSQLDBSocketConnectionProperties on client. Now I load data in T..ObjectDynArray and display data in VirtualStringTree like a DBGrid. Works well and fast but need a lot of boilerplate code. You define dataset fields from TSQLRecord props. I will try from data in ISQLDBRows interface.

#48 Re: Free Pascal Compiler » Using Lazarus DBGrid with mORMot. » 2020-06-11 18:43:31

Thanks AOG, but this unit is not replacement for SynDBMidasVCL I need dataset from SynDB server to execute any query in existing not ORM Firebird DB.

#49 Re: Free Pascal Compiler » Using Lazarus DBGrid with mORMot. » 2020-06-11 15:47:51

AOG wrote:

I am using the mORMot for filling DBGrids with Lazarus.
The TBufDataset is very suitable. It is used in SynDBMidasVCL.
Works very well.

@AOG I can't compile trunk mORMot SynDBMidasVCL.pas with Lazarus 2fix, fpc 3.2fix. Do you have custom version, can you upload your version. SynDBMidasVCL use SynDBVCL and first error is in PSGetTableName, function GetTableNameFromSQL come from dbcommon Delphi only, I change to:
result := {$ifdef fpc}'' {$else} GetTableNameFromSQL(fCommandText){$endif};
Next error is in SynDBMidasVCL line 281 function From don't exist.
Any hint how you use dataset in Lazarus.

#50 mORMot Framework » TNullableUTF8Text return empty string not null » 2020-05-23 12:33:27

ttomas
Replies: 0

I have TSQLRecord with published TNullableUTF8Text property and inserted some null values.
MultiFieldValues or RetrieveDocVariantArray returns JSON "field_name": '', not "field_name": null.
I checked db with DB Browser for SQLite, fields are NULL in db. This result are for FPC 3.2fix, Win32/64 and Linux64.
I checked select * from table with SynDBExplorer build with Delphi 2007 and Export to JSON returns null as I expect.
Is this a bug or expected for FPC?

Board footer

Powered by FluxBB