[fpc-devel] Should TAutoIncField be read only?
Joost van der Sluis
joost at cnoc.nl
Thu May 20 10:27:33 CEST 2010
On Wed, 2010-05-19 at 14:14 -0300, Luiz Americo Pereira Camara wrote:
> Joost van der Sluis escreveu:
> > On Wed, 2010-05-19 at 00:32 -0300, Luiz Americo Pereira Camara wrote:
> >
> >> Until a few moments ago i would say yes because it seems logical and fpc
> >> raises an exception when trying to set the value programatically.
> >>
> >> But while investigating why TAutoIncField.ReadOnly always returns false,
> >> i found that, regardless of FReadOnly being set to true in the
> >> constructor, this value is overriden in TFieldDef.CreateField throung
> >> Attributes.faReadOnly flag.
> >>
> >> So i tested in Delphi (TClientDatset and TDbf) and found that
> >> TAutoIncField.ReadOnly is false (like fpc).
> >>
> >> So what should fpc do:
> >> - Follow delphi behavior and let TAutoIncField.ReadOnly return False?
> >> - Fix TAutoIncField.ReadOnly to return True?
> >>
> >
> > That's not fixing it, that's breaking it. Readonly have to be false for
> > autoincremental fields.
> >
>
> I'm just confused by the exception that is raised ("autoinc fields are
> read only") when trying to set a value and by the code in the
> TAutoIncField constructor that initializes FReadOnly to true.
>
> Attached is a patch that removes this initialization.
That's indeed strange. And it would mean that those fields are
effectively readonly. I think they shoudn't be. (But to be sure, if it
would have been my design, there woudn't be such a thing as an autoinc
field.)
I see two choices: make it possible to edit autoinc fields, or make
ReadOnly true.
Maybe we should choose the second option, for Delphi-compatibility?
Joost.
More information about the fpc-devel
mailing list