#2 mORMot 2 » Rest server do not include Content-Type in header » 2023-11-29 08:06:16

Replies: 1

Hi ab, I have a situation where I only want to return http status code, currently the http rest server always sets Content-Type header to json unless overriden but there doesn't seem to be an easy way to control this via context in method based services.
It would be nice if there was a boolean property in TRestServerUriContext that would control that or even better if there were another overloaded Returns method that only specifies the status code.

best regards

#3 mORMot 2 » rtti bug (stable, trunk) » 2023-11-26 10:01:20

Replies: 0

Hi ab,
please check Pull request on github.
best regards.

#4 Re: mORMot 1 » Batch columns and values mismatch » 2022-11-19 07:52:02

Because it only happens at specific record count it's probably a JSON buffer issue. This is more true because if you add/delete properties from your TOrm class then the problematic record count changes.

#5 Re: mORMot 1 » Batch columns and values mismatch » 2022-11-14 18:39:57

Under certain conditions the internal encoding of a TRestBatch.add action changes.

Problem can be traced to mormot.orm.sqlite3, specifically to procedure TRestOrmServerDB.InternalBatchStop, specifically lines 2615-2628.
When the encoding is in BATCH_DIRECT_ADD it makes a call to EncodeMultiInsertSQLite3 with the SimpleFields parameter. Because TRecordVersion is not a "SimpleField" it's not accounted for and as such a discrepancy occurs between number of bits in SimpleFields (n) and actual fieldCount (n + 1) getting passed to this procedure.

Anyway, that's all from me, don't have the time right now but I hope this helps a bit.

#6 Re: mORMot 1 » TRestClientDB or direct access to TRestServerDB for a server » 2022-10-29 11:08:01

dcoun wrote:

Do you mean that I should use a TrestClientDB.Create(aRunningServer: TRestServerDB) ?

No, you should use an instance of TRestServerDB directly on server side.

dcoun wrote:

I already have enabled PUREMORMOT2, I create a TRestServerDB instance before the http server and I can still have access to TRestServerDB.orm.add

Yes, that is the correct way.
FDatabase.Orm.Add where FDatabase is an object instance of TRestServerDB class.

#7 Re: mORMot 1 » TRestClientDB or direct access to TRestServerDB for a server » 2022-10-29 10:32:09

is it better to use TRestServerDB's orm interface directly ?

that's how you're supposed to use it.  The only reason you can still call Add/Update/Delete directly from the TRestServerDB instance is because it's there for backwards compatibility with mORMot 1. If you define PUREMORMOT2 flag for your project then you will see those direct methods no longer available.

I believe that a REST interface procedure in a server called by a client will not have problems to access a main-central TRestServerDB instance to do database work

By default there is a lock at orm level so all threads orm access will be properly synchronized, shouldn't have a problem.

#8 Re: mORMot 1 » TRestServerDB.orm.OneFieldValues needs RowID instead of ID » 2022-07-14 05:23:39

Isn't this just based on what the chosen database uses for the primary indexed column name in every table? For example, if you're using sqlite then yes you need to use RowID because that's the name of the indexed column, and you only have to do that anyway (AFAIK) if you bypass the ORM layer.

#9 Re: mORMot 1 » mORMot 2 Release » 2022-06-08 07:47:28

I'm in same boat as sakura, basically I've switched to mORMot 2 during development but aren't using it in production yet because the project isn't there yet.

#10 Re: mORMot 1 » New Async HTTP/WebSocket Server on mORMot 2 » 2022-05-22 06:12:20

Looking forward to testing it out, cheers.

#11 Re: mORMot 1 » Found sqlite-gui - a lightweit but quite usable sqlite manager tool » 2022-05-21 11:35:18

Interesting, I personally use "DB Browser for Sqlite" also known as sqlitebrowser, open source tool https://github.com/sqlitebrowser/sqlitebrowser

#12 Re: mORMot 1 » Enhanced URI routing for method-based services » 2022-05-13 10:30:20

You can with nginx, I don't use IIS. I don't know why you would want to remove method name, with mORMot you can dynamically link a method to any string using TRestServer.ServiceMethodRegister(...).

#13 Re: mORMot 1 » Enhanced URI routing for method-based services » 2022-05-13 08:51:49

tbh the no root is better to be handled by whatever front-end reverse/balancing proxy you are using. It's trivial to do this in nginx.

#14 Re: mORMot 1 » MVC URI routing » 2022-05-12 11:21:08

Just a wild guess,
I assume your browser test is using a GET request, you should make a POST request instead. From the browsers perspective you're trying to access a cacheable resource, there's no reason to send a second request for the same resource if the first one is still waiting for server response. Either POST request or append a different parameter(Y) to the GET request for each X /root/example/delay?X=Y.

#15 Re: mORMot 1 » MVC URI routing » 2022-05-12 08:16:09

squirrel wrote:

How would I then find and execute the correct function on that interface with the correct parameters?  I assume I'll have to search for the methodindex from the interfacefactory and then step through and assign the declared parameters?
Have someone done something like this before?

Since ExecuteCommand is private, how would the function be called after the parameters are assigned?

AFAIK it's already documented on how to call interface based services on server side : https://synopse.info/files/html/Synopse … #TITLE_421

#16 Re: mORMot 1 » TDocVariant.names raise AV » 2022-05-06 08:08:39

can you try without variant late binding?

var v : variant;
  with TDocVariantData(v) do
     U['Code'] := '000';
     U['Descr'] := 'xxx';
     Names[0] := '222';

#17 Re: mORMot 1 » Benchmark PostgreSQL, SQLite and mORMot » 2022-05-03 08:43:24

The issue you have is that you're executing database requests in the same thread as the user UI which is just bad all around. You should decouple your logic from the UI. Database requests should be done in a separate thread. However, this requires some threading knowledge on your own part. Please read : https://synopse.info/files/html/Synopse … #TITLE_304

#18 Re: mORMot 1 » Benchmark PostgreSQL, SQLite and mORMot » 2022-05-03 07:23:54

let me rephrase , why exactly do you care if a batch transaction takes 50 ms? Does your client application lock up and stop responding?

#19 Re: mORMot 1 » Benchmark PostgreSQL, SQLite and mORMot » 2022-05-02 10:27:44

Correct me if I'm wrong, but it seems from your comments that your primary concern is the user UI stalling/locking/delaying due to waiting for database action to complete?

#20 Re: mORMot 1 » Suddenly getting "Method Not Allowed" after updated mORMot » 2022-04-30 06:19:29

I wasn't referring to the screenshot per se

edwinsn wrote:

since I've done minor changes in SynCommons.pas, it somehow  failed to update/merge that file.

I would 100% expect tortoise to not auto overwrite your modifications if the two conflicted. Maybe you encountered a bug like you said but this just sounds normal operation to me. I've done the same thing in the past, I introduced manual changes in SynCommons for debugging or some other reason and tortoise would always soft-fail the repo update and I either had to dismiss my changes or manually merge the file in question.

Then again this is software big_smile, maybe you were/are using a tortoise version where such a bug exists. OR perhaps it has something to do with using a Subversion tool to update from a git repo, that may very well be the case.

#21 Re: mORMot 1 » Suddenly getting "Method Not Allowed" after updated mORMot » 2022-04-29 10:37:09

Nice that you found out why but it really isn't the tools fault, there was clearly a conflict with your manual changes. The tool did it's job and prevented the loss of your modifications, it warned you that there is a conflict but you probably just closed the window. What you had to do is to click on the conflicted file in the update window and click manual resolve.... Then you would get an editor where you could manually merge or update the conflicted lines. The same thing would happen if you used any other tool/client.

I also like the Tortoise client, the only thing I change is that I use Beyond Compare as the editor of choice for merges&conflicts, highly recommend.

#22 Re: mORMot 1 » mORMot 2 commit build number reset to 2.0.1 » 2022-04-20 05:43:26

I found it way easier to just write little pascal programs in fpc then trying to understand some bash, awk, seed or regex crap ...
You can execute external programs with little effort using TProcess, https://wiki.freepascal.org/Executing_E … s#TProcess.
I haven't had any problems so far using this method.

#23 Re: mORMot 1 » How to correctly call TRestServerDB.TransactionBegin? » 2022-04-10 07:34:55

Oh, didn't know you are using postgre, I have no experience with that database, maybe someone else will chime in, gl.

#24 Re: mORMot 1 » How to correctly call TRestServerDB.TransactionBegin? » 2022-04-08 07:05:05

manually call TransactionBegin,Commit,Rollback, etc... and for vanilla sqlite the transaction will apply to the entire database.

#26 Re: mORMot 1 » mORMoti18n - LANGUAGE_NONE » 2022-04-01 09:56:08

ab wrote:

Where to report the problem?

fpc-devel mailing list is very active and probably will get noticed sooner then creating a git issue.

#27 Re: mORMot 1 » THttpClientSocket with Basic authentication returns empty content » 2022-04-01 06:32:11

dcoun wrote:

I have managed to force fpcupdeluxe to install Free Pascal Compiler version 3.2.0-r45643 [2022/04/01] for i386

Not sure where you got that date from but 3.2.0 was released in 2020. Honestly if you're having issues just download 3.2.0 from offical freepascal webpage.

#28 Re: mORMot 1 » THttpClientSocket with Basic authentication returns empty content » 2022-03-29 09:57:04

maybe his lib paths are wrong and is compiling/linking older version. Check your paths and do a full clean+build.

#29 Re: mORMot 1 » Mormot2 server as library + a relocate error in linux » 2022-03-14 07:37:45

mORMot links external object files that haven't been compiled with -fPIC, you can avoid the errors by using external libraries instead,
for the errors you provided you need to set the following compile time flags :


You can do this on command line or if IDE , for example lazarus ide :
Project Options -> Compiler Options -> Custom Options

I've done this for a different reason then you and I don't recommend it unless you are a seasoned veteran of writing external libraries. Things like shared memory will be prohibited because the framework wasn't designed with relocatable code in mind. mORMot has a lot of initialization hooks that hook into exceptions, rtti and system units and while there are (some) compile time flags that control this behavior it really goes against the "grain" of the project and may result in unwanted behavior.

That much said, if you don't care about shared memory, mORMot will work just fine in a library after all, without shared memory there's little difference between a program and a library.
For your use case I fail to see why you would want to use a library instead of a normal program, everything you mentioned can be achieved with writing a normal program and in your case there's only disadvantages to using a library instead.

#30 Re: mORMot 1 » Stop the war! » 2022-02-24 08:20:07

Stay safe Pavlo! Slovenia is a small country but our government and we the people fully support the Ukrainians and your right to exist as a nation. The EU nations must come together on this or EU be damned!

#31 Re: mORMot 1 » Mormot2 orm unavailable » 2022-02-23 12:20:10

Hard to tell unless you provide a minimal example we can test, tbh I suspect it might be the new httpasync server which is the default in mORMot 2, can you test with the normal http socket server, or if you're using websockets, BidirSocket server.

TRestHttpServer.Create(..., TRestHttpServerUse.useHttpSocket,..l);

#32 Re: mORMot 1 » strings code Different in client and server » 2022-01-26 12:12:51

You need to provide more info, compiled with Delphi? Which version? Both client and server using same compiler & build mode? Modern Delphi string type is UnicodeString by default UTF-16 encoded so as expected uses more space then UTF-8 encoded rawutf8.

#33 Re: mORMot 1 » Advice on server side memory consumption issue.. » 2021-12-18 08:00:30

hey, the memory numbers you see in the process tab of the task manager are just a crude approximation of actual memory used. If you have a lot of heap de/allocations like in your case then you are bound to have some heap fragmentation. This means the heap memory will grow over time (but should stabilize) which is what you are observing. There's not much wrong with that since the memory manager will try to reuse the fragmented space.

Absolutely the better way is to use a memory profiler instead of the task manager. If you have to use external software then the better choice is Microsoft's Process Explorer from SysInternals (You would look at the "Private Bytes" statistic of Virtual Memory), but again, it's all just crude approximation.

#34 mORMot 1 » NoExceptionIntercept conditional » 2021-12-17 15:14:24

Replies: 1

Currently on mORMot 2, latest revision, can't compile if NOEXCEPTIONINTERCEPT is defined, cheers.

#36 Re: mORMot 1 » [mORMot2] ECC static lib » 2021-09-18 14:49:45

that's fine, don't care about the size, I wanted to create a lib (.so) using mormot2 and the linker complained that ../static/x86_64-linux/ecclin64O2.o wasn't compiled with -fPIC so needs to be recompiled. Since I couldn't find the source code it was easier to just switch to openssl to keep the linker happy.

#37 mORMot 1 » [mORMot2] ECC static lib » 2021-09-18 10:11:50

Replies: 4

Hi ab , right now the static lib always gets linked even if using openssl instead, can we change this? I think {$define ECC_STATICLIB_AVAILABLE} should be moved to mormot.defines.inc or some other global switch should be made.

#38 Re: mORMot 1 » mORMot2 fpc linker error » 2021-09-15 11:47:29

thanks ab, I will stick to trunk for now and revert to 3.2.2 if necessary because I don't use variant late bindings.

btw, this forum desperately needs a thumbs up functionality for posts to reduce the amount of "thank you" replies big_smile

#39 Re: mORMot 1 » mORMot2 fpc linker error » 2021-09-15 10:32:44

Nice, I didn't even know someone was creating deb packages (I heard it's PITA), I think both ways should be documented. Also for the packages, a hash should be posted in the documentation, for security.

#40 Re: mORMot 1 » mORMot2 fpc linker error » 2021-09-15 08:41:14

I've just compiled this example (and my project) successfully with FPC trunk 3.3.1-9066-gffc3e1780d [2021/09/14], so whatever bug seems to have been fixed somewhere after 3.2.2 stable.
FPC 3.2.0-r45643 is over a year old, when fpc team tags next stable release 3.3.x, consider testing mORMot 2 for that revision.

Another thing, since fpc source moved to gitlab, fpcupdeluxe wont accept the svn revision number r45643 because git hashes are now the "revision number", this makes documentation for installing on Linux obsolete.

#41 Re: mORMot 1 » mORMot2 fpc linker error » 2021-09-15 08:00:58

Initialization is not the problem, in my project I have everything set up correctly with constructor&destructor in a try..finally block and still produces this bug, I also tested it on this MWE example.
It's not that big of a deal tho because nobody should be calling ItemPtr function in production anyway since you can access the original Array directly, however it would be nice if TSynDictionary would have a public function that gives you a pointer to the start of the Keys & Values array respectively.

#42 Re: mORMot 1 » mORMot2 fpc linker error » 2021-09-14 17:40:54

FPC bug for sure, I just wanted to know if anyone else can reproduce it or if it's just my system that is borked.

the main begin.end block isn't the culprit, this is just a MWE example, I did test it in a sub-procedure originally. I bet the bug has something to do with namespaces , the monolithic unit structure of mORMot 1 didn't trigger this bug on the same compiler version.

#43 mORMot 1 » mORMot2 fpc linker error » 2021-09-14 11:38:50

Replies: 11

I get a linker error when trying to build/compile this simple program

undefined reference to `.Lj14'
program test;

{$I mormot.defines.inc}

uses {$I mormot.uses.inc}

  P: Pointer;
  FDictionary: TSynDictionary;
  P := FDictionary.Keys.ItemPtr(0);

Builds OK if ItemPtr Index parameter is > 0.

Debian buster
FPC 3.2.0-r45643
No optimizations

I also tried on FPC stable 3.2.2.

#44 Re: mORMot 1 » Fast MM5 » 2021-08-10 13:13:54

thx ab, I will be using fpcx64mm as I gradually move over to mORMot 2.

#45 Re: mORMot 1 » Fast MM5 » 2021-08-10 11:03:10

Anyone here who likes to modularize their applications (linux) by writing dynamic libraries? If so, do you use shared memory manager and which one? Any pitfalls and recommendations ?

#46 Re: mORMot 1 » What does UrlDecodeDouble do » 2021-08-03 11:05:41

Upper = Upper of the target parameter? Why?

Because it's faster, reduces the time spent in the lookup table comparing chars.

Next = this is not obvious to me

Moves the string char pointer to the next to be decoded value, this is again performance benefit so it doesn't have to re-scan the entire URL string every time you call UrlDecode functions.


URL : user=Peter&password=test
if UrlDecodeValue(U, 'USER=', LUser, @U) and UrlDecodeValue(U, 'PASSWORD=', LPassword) then

#47 Re: mORMot 1 » Grace is an idea for mORMot - upgrade server with zero downtime » 2021-04-22 11:54:34

danielkuettner wrote:

Contabo is top! I used there services since 2018 without issues.

VPS or dedicated?

#48 Re: mORMot 1 » Grace is an idea for mORMot - upgrade server with zero downtime » 2021-04-22 06:24:46

those prices at Contabo are just ridiculous, looking at some customer experiences on social sites, the performance seems to be terrible, possibly due to running shoddy hardware and over provisioning multiple users on the same node.

#49 Re: mORMot 1 » Front desk method based service class with jwt authentication » 2021-04-03 09:00:33

I think you missed the point ab made, you don't have to prompt login, just renew the token before it expires. You can track expiration js client side and have client submit a renewal request to the server.

#50 Re: mORMot 1 » Method based services optExecInMainThread » 2021-03-31 12:31:45

You can set the execution mode for method based services in your TSQLRestServer

FServer.AcquireExecutionMode[TSQLRestServerURIContextCommand.execSOAByMethod] := amMainThread; 

Board footer

Powered by FluxBB