[fpc-devel] restbase.pp LoadFromJSON calling StopRecordPropertyChanges;

Wayne Sherman wsherman at gmail.com
Mon Jan 16 21:16:40 CET 2023


On Sun, Jan 15, 2023 at 9:28 PM Michael Van Canneyt wrote:
> On Sun, 15 Jan 2023, Wayne Sherman wrote:
> > On Sun, Jan 15, 2023 at 9:24 AM Michael Van Canneyt wrote:
> >> On Sat, 14 Jan 2023, Wayne Sherman wrote:
> >>
> >>> I see a couple of problems TBaseObject.SaveToJSON
> >>>
> >>> 1) TBaseObject.SaveToJSON cannot distinguish properties that are part
> >>> of the REST protocol from properties that are not part of it.  It only
> >>> knows that properties which have been modified are part of the rest
> >>> protocol, but properties which have not been modified might be part of
> >>> the REST protocol or might not be.  For example, a client receives a
> >>> JSON object from a server (via LoadFromJSON) and wants to persist the
> >>> complete JSON object to disk, database, or send it to another server.
> >>> But, at present, there is no way to save all the properties that are
> >>> part of the REST protocol without getting contaminated with non-REST
> >>> properties.
> >>
> >> The non-REST properties will never be marked as changed, so they will not be
> >> saved.
> >
> > LoadFromJSON calls StartRecordPropertyChanges and
> > StopRecordPropertyChanges.  Both of these destroy the change records.
> > At present, there is no opportunity to save modified records after
> > loading.  If that was fixed I think it would be a step in the right
> > direction.
>
> It seems to me we're talking cross-purpose. From my point of view,
> the code works as designed. It has been in use in production since many
> years (in fact, since it was committed to FPC).
>
> Can you please make a small example that demonstrates the problem you are
> experiencing, so I can look at it ?

Ok, I will see if I can create a demo.  I need clarification about the
auto generated class index specifiers.  Do they always start at 0 in
each descendant class, or are they unique across all descendant
classes?

TBaseObject --> TChild --> TGrandChild

TChild = class(TBaseObject)
...
  published
    property Field1: string index 0...
    property Field2: string index 8...
  end;

TGrandChild = class(TChild)
...
  published
    property Field3: string index 16...  // does this continue at 16
or start at 0 again?
    property Field4: string index 24...
  end;


More information about the fpc-devel mailing list