[fpc-devel] Should TAutoIncField be read only?
Luiz Americo Pereira Camara
luizmed at oi.com.br
Wed May 19 19:10:11 CEST 2010
Michael Van Canneyt escreveu:
> On Wed, 19 May 2010, 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?
> As far as I know, you can force a value for an autoinc field, so it
> is not always read-only. AutoInc means the engine will assign a value
> if none is given at insert.
Trying to set value through TField.AsInteger or TField.Value raises an
exception (autoinc fields are read only) both in Delphi and fpc.
More information about the fpc-devel