[Pas2js] Cannot access Rows property

Michael Van Canneyt michael at freepascal.org
Sat Mar 17 16:04:55 CET 2018



On Sat, 17 Mar 2018, warleyalex via Pas2js wrote:

> reference: JSONDataset unit
>
> for datastores I use the base class TJSONDataset which inherits from the
> TBaseJSONDataset.
> the issue is the Rows property is implemented on the protected scope!

That is by design. 
TJSONDataset is also an abstract class, not meant to be used directly.

>
> I think the following properties should live on the public / published scope
>
>    // If True, then the dataset will free MetaData and FRows when it is
> closed.
>    Property OwnsData : Boolean Read FownsData Write FOwnsData;
>    // set to true if unknown field types should be handled as string
> fields.
>    Property MapUnknownToStringType : Boolean Read FMUS Write FMUS;
>    // Metadata
>    Property MetaData : TJSObject Read FMetaData Write SetMetaData;

It has no sense to make this public, you need a format for metadata. 
The format must be defined by a descendent. This can then choose to make the
metadata public or not.

>    // Rows
>    Property Rows : TJSArray Read FRows Write SetRows;

I definitely think this should not be made public, since you can then 
manipulate the data without going through the TDataset API. That is not the
idea :)

>    // Fieldmapper
>    Property FieldMapper : TJSONFieldMapper Read FFieldMapper;

OK for this.

>    // FieldClass
>    Property UseDateTimeFormatFields : Boolean Read FUseDateTimeFormatFields
> Write FUseDateTimeFormatFields;


Again, this depends on the format of the data, which is only known to
descendents.

TJSONDataset is still an abstract class. It's not meant to be used directly,
it just serves to avoid having to declare all TDataset events published.

It's up to descendents to decide what to make public and what not.

You need a descendent anyway to implement the following abstract methods:
  Function CreateFieldMapper : TJSONFieldMapper; virtual; abstract;
  Procedure MetaDataToFieldDefs; virtual; abstract;


Michael.




More information about the Pas2js mailing list