#1 2012-12-17 10:44:13

h.hasenack
Member
From: Nijmegen, Netherlands
Registered: 2012-08-01
Posts: 173
Website

Creating a TPersistent alike property in TSQLRecord

Hi Ab

I am fiddling to load and write an object that contains a Tpersistent derived property.

This property needs to go into a (probably custom) blob field as is size (and class) is only known during runtime. Usually I use the ObjectBinaryToText routines to generate text from my object resources.

I have tried using TSQLPropInfoCustom, but I run into the reader and writer parameters provided. I was expecting something like

  TOnSQLPropInfoRecord2Text = procedure(const Data; DataLen: integer; var Text: RawUTF8);
  TOnSQLPropInfoRecord2Data = procedure(const Text: RawUTF8; var Data); 

but actually, the code in mormot.pas looks like:

  TOnSQLPropInfoRecord2Text = procedure(Data: pointer; DataLen: integer; var Text: RawUTF8);
  TOnSQLPropInfoRecord2Data = procedure(Text: PUTF8Char; var Data: RawByteString);

What way would you advise to load/save TPersistent objects together with my TSQLRecord?

Regards - Hans

Offline

#2 2012-12-17 10:59:40

h.hasenack
Member
From: Nijmegen, Netherlands
Registered: 2012-08-01
Posts: 173
Website

Re: Creating a TPersistent alike property in TSQLRecord

I think I have worked around it. I'm using a TSQLRawBytes to store my Delphi stream. Previously I stored a TMemorySTream during runtime of by object) but this is just as efficient and also allows the blobreartieve and update routines to work as expected.

My error. - Sorry.

Offline

#3 2012-12-17 17:29:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Creating a TPersistent alike property in TSQLRecord

I suppose it was the easiest to do, without changing the current implementation.

RawByteString or TSQLRawBlob is in fact a good way of storing some BLOB content, without having to worry about freeing the memory, as is required by TMemoryStream.

You have the TRawByteStringStream class in SynCommons.pas to work efficiently with TStream methods, with direct conversion to/from a RawByteString.

Offline

#4 2012-12-18 07:29:30

h.hasenack
Member
From: Nijmegen, Netherlands
Registered: 2012-08-01
Posts: 173
Website

Re: Creating a TPersistent alike property in TSQLRecord

The big issue was that we forgot to implement the ftsBlob handlking in our nexus driver yikes
Once this was fixed, it worked like a charm

Offline

Board footer

Powered by FluxBB