Menu

#624 TZQuery does not commit ReadOnly Fields

8.0.0
open
nobody
TZQuery (3)
Bug Report
2025-05-11
2025-03-31
MmVisual
No

I have some fields, they are for the user ReadOnly. But the program can change this:

q1.FieldByName('Status').ReadOnly := False;
q1.FieldByName('Status').AsInteger := 1;
q1.FieldByName('Status').ReadOnly := True;

But:
q1.Post;
does not commit the change into the database, but the change is visible in the TDBGrid after post. After close an reopen the q1 the old value is there.

The Field has the ProfiderFlags.pfInUpdate set.

All other fields where are ReadOnly = False works well.

Thank you very much for fixing.

Discussion

  • MmVisual

    MmVisual - 2025-04-01

    I have fix this bug. I have delete the code in line 760: "Metadata.IsReadOnly(I)".

    ZDbcGenericResolver:
    procedure TZGenerateSQLCachedResolver.FillInsertColumnsPairList(NewRowAccessor: TZRowAccessor);
    : :
    if (Tmp = '') or ( Metadata.IsReadOnly(I) or ) not Metadata.IsWritable(I) or
    : : :

    Please commit this code into the original source.
    Thank you very much.

     
    • marsupilami79

      marsupilami79 - 2025-05-11

      I think Zeos behaves as intended here. Modifying the ReadOnly attribute of a field is not supported. Maybe you should move the following line to the AfterPost and Cancel events:

      q1.FieldByName('Status').ReadOnly := True;

       
  • MmVisual

    MmVisual - 2025-05-11

    In Zeos V7.2.14, changed fields that are ReadOnly were always written to the database.
    If this is no longer the case with Zeos V8, then there should at least be a property in TZConnection:CommitReadOnlyFields True/False

    The way you have written it does not work, I have tested it:

    OnBeforePost() >>> ReadOnly:=False

    OnAfterPost() >>> ReadOnly:=True

    does not work, because Zeos already calculates which fields should be written before calling OnBeforePost() and if I set the ReadOnly to False in OnBeforePost(), the field is still not written to the DB.

    Anyway, if this remains as it is, many Zeos V7 users who have not yet switched to Zeos V8 will complain ;-)

     
  • MmVisual

    MmVisual - 2025-05-11

    Here my change, this works good for me.

     

Log in to post a comment.

MongoDB Logo MongoDB