#1 mORMot 1 » FTS: best practice for multiple documents per object » 2017-12-28 17:26:24

gothbert
Replies: 0

Hi,

my use case is as follows:
- several classes (TSQLRecordPerson, TSQLRecordLocation, ...) with one-to-many relationships to documents
- one document belongs to exactly one object
The documents are derived from TSQLRecordFTS5Unicode61.

According to SAD and this post, it is best to use TRecordReferenceToBeDeleted as DocID. Thus the returned DocID set from an FTS query allows direct access to the related TSQLRecordPerson, TSQLRecordLocation, ... objects.

Question is how to extend this to the case of several documents per object.

Some help would be appreciated.

Best regards
Boris

#2 Free Pascal Compiler » 26 - RESTful ORM/RESTserver segfaults at termination » 2017-12-26 19:33:26

gothbert
Replies: 0

Hi,

using Lazarus 1.8.0 with fpc 3.0.4 under Windows 10, target x86_64, mode Delphi.

RESTserver example compiles and runs. On termination, after Enter key is pressed, a Segmentation fault occurs.

With the aid of the debugger, I could track down the issue to the inherited call in the destructor of TSQLRestServerFullMemory in mORMot.pas.

destructor TSQLRestServerFullMemory.Destroy;
begin
  UpdateToFile;
  inherited;
end;

Exception occurs at SYSTEM_$$_REMOVE_FREED_FIXED_CHUNKS$POSCHUNK

No such issues under Delphi 10.2.2 (Tokyo).

What I can do to fix the issue?

Best regards
Boris

#3 Re: mORMot 1 » [Solved] Extracting and comparing single characters in RawUTF8 strings » 2017-12-22 18:21:37

Thank you, mpv, that does the job.

There is a lot of pointer arithmetic involved in getting the job done, plus some pitfalls. Here is what I learned:

RawUTF8 strings behave like pointers.
p= pointer(S) makes a PUTF8Char point to the beginning of the RawUTF8 string S. Do not use p:= @S.
K:= S makes K point to the same memory as S. Even K:= Trim(S) does so. I needed to make an explicit copy by K:= Copy(S, 1, Maxint).

#4 mORMot 1 » [Solved] Extracting and comparing single characters in RawUTF8 strings » 2017-12-22 11:02:48

gothbert
Replies: 2

Hi,

I would like to transform a RawUTF8 string character-wise, in particular remove underscores and move all initial lowercase characters to the end (de_la_Rue -> Rue!dela). To do so I run over the characters in the RawUTF8 string N and its LoweCaseUnicode() copy L as

while (i <= len) and (N[i] = L[i]) do ...

This does not work for non-7-bit characters like é and ä. This is probably due to the UTF-8 encoding and N[] returning a single byte instead of a single char.

What is the correct way of accessing the ith character in a RawUTF8 string?

Best regards
Boris

#5 Re: Free Pascal Compiler » [Solved] TSQLModel.GetTableIndex: Props is garbage under fpc 3.0.4 » 2017-12-18 11:01:08

Thank you, AOG, for the quick reply!

Using your guidance, I made the sample program run. With the same settings, mine didn't. Comparison showed that I used the AutoFree pattern for adding records and that fails under FPC. I had better studied the fine manual more thoroughly because the issue is described there. Using the try/finally pattern or assign the result of the AutoFree() call to a variable does the job.

#6 Free Pascal Compiler » [Solved] TSQLModel.GetTableIndex: Props is garbage under fpc 3.0.4 » 2017-12-17 22:03:52

gothbert
Replies: 2

Hi,

I made a trimmed-down version of the 26 - RESTful ORM example with Lazarus 1.8.0/Free Pascal Compiler 3.0.4 under Windows 10 64bit (target windows x86_64).

The server component runs fine. The client component creates a SIGSEV when doing Client.Add(). It looks like the pointer magic

Props := PPointer(PtrInt(aTable)+vmtAutoTable)^;

in mORMot.TSQLModel.GetTableIndex() returns a pointer into Nirvana: Props is filled with random content.

Delphi 10.1 creates a working executable, though.

SynCommons.VarRecToTempUTF8() seems to produce a similar issue in the vtClass branch of the case statement.

Is there a compiler switch to make the pointer magic work with Free Pascal or any other solution for this issue?

Best regards,
Boris

#8 mORMot 1 » [SOLVED] d8419c65eb5ec76ae57938f85c7511735e1fcb2e breaks SynSelfTests » 2017-12-13 13:51:35

gothbert
Replies: 2

Hi,

making first steps with mORMot. Could compile and run self-test yesterday evening with Delphi 10.1. Current version from master breaks SynSelfTests.pas at line 16941:

SynSelfTests.pas(16941,17) Error: Incompatible types: got "TWebSocketProtocol.Clone(const RawUTF8):TWebSocketProtocol;" expected "TWebSocketProtocol"

Identical behavior in Lazarus 1.8.0/FPC 3.0.4 on Linux (amd64) and Windows (64bit).

What should I use as argument in Clone() for a quick fix?

Best regards,
Boris

#9 Re: mORMot 1 » Accessing legacy flat-file database from mORMot » 2017-12-05 17:44:13

Great, thank you, Arnaud, for the fast reply and the advise with the steps to follow. Now I will have something to do during the holiday season :-)

#10 mORMot 1 » Accessing legacy flat-file database from mORMot » 2017-12-04 18:52:22

gothbert
Replies: 2

Hi,

since 1990 I develop a specialized application based on a self-designed flat-file database in my spare time. With hundreds of databases being around and limited development time, a big bang migration to a modern backend (RMDBS) is not feasible. I therefore would like to use the mORMot framework and a custom backend to encapsulate access to the legacy database. Is this possible/advisable, and if so, could I please have some hints how to start?

The legacy flat-file database is a set of files in a folder with one file per entity and the position of the record in the file as ID. BTrees persistent in files are used to determine the sort order. The largest database is 120 MB, i.e. would nicely fit into memory/cache for queries. Delphi code already exists to read, modify, append, delete records and update the BTrees accordingly.

Kind regards
Boris

#11 PDF Engine » Boxes on canvas not rendered correctly in PDF » 2017-11-08 20:30:35

gothbert
Replies: 0

Hi,

I am a happy user of the SynPDF library for rendering PDF from RichText in conjunction with TPrintPreview.

I recently developed a program to plot ancestry charts with boxes with rounded edges and lines between them on a canvas using RoundRect() and PolyLine() in Delphi 10.1. In the PDF created from the canvas the boxes are strangely distorted and the lines are missing, though.

Would it make sense that I provided a sample program to reproduce the issue such that someone with some knowledge of the SynPDF.pas code could have a look at the cause and correct the behavior?

Kind regards
Boris

Board footer

Powered by FluxBB