Shadowed properties cause errors during FieldDef initialization
If a child class publishes a property with the same name as a parent class, TObjectDataSet
will attempt to add multiple fields with the same name, which leads to an error.
It feels most appropriate to me for the property from the child class to be used. This can be achieved by only including the first property for a given name when enumerating the properties in InitRttiPropertiesFromItemType
(thereby excluding the duplicates from fProperties
) or by doing a similar thing inside InitRttiPropertiesFromItemType
where the TFieldDef
s are added.
Comments (3)
-
repo owner -
reporter I don’t think it’s fixed in the latest
develop
branch.Here’s a minimal reproducible case for this issue which should work on both
master
anddevelop
.program ShadowedPropertyBug; uses Spring.Data.ObjectDataSet, Spring.Collections; type TFoo = class(TObject) private FBar: Integer; published property Bar: Integer read FBar write FBar; end; TBar = class(TFoo) published property Bar: Integer read FBar write FBar; end; var ods: TObjectDataSet; begin ods := TObjectDataSet.Create(nil); ods.datalist := TCollections.CreateObjectList<TBar> as IObjectList; // error on open: Duplicate name 'Bar' in TFieldDefs ods.open; end.
It might be useful to add a note to the ‘Know Issues’ section of the README in the
master
branch that mentions that the latest bug fixes are only found in thedevelop
branch.
I didn’t think to use anything butmaster
when starting out with Spring4D. -
repo owner - changed status to resolved
fixed
#390→ <<cset dc0bc32a013c>>
- Log in to comment
Isn’t that also already fixed in 2.0? Please retest