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.
Luiz
Index: fields.inc
===================================================================
--- fields.inc (revision 15279)
+++ fields.inc (working copy)
@@ -1706,7 +1706,6 @@
begin
Inherited Create(AOWner);
SetDataType(ftAutoInc);
- FReadOnly:=True;
FProviderFlags:=FProviderFlags-[pfInUpdate];
end;
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel