[fpc-devel] Should TAutoIncField be read only?

Joost van der Sluis joost at cnoc.nl
Wed May 19 09:30:07 CEST 2010

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.

One widely used method, for example, for using autoinc field and cached
updates is setting the values of the autoinc fields to negative values
when new records are created. That way you can make master-detail
relations without having to apply all updates to the datasets. 
That's not possible anymore when you make those fields readonly.


More information about the fpc-devel mailing list