Page 1 of 1
Column Date and Validating issue
Posted: 27.04.2021, 14:57
by louis
Hello,
I try to upgrade my application from Zeos 7.2.0b to 8.0.0-r7490.
This code present in the OnValidate event of the column DATA_REGISTRAZIONE:
Code: Select all
procedure TForm11.ztbDocTestaDATA_REGISTRAZIONEValidate(Sender: TField);
begin
zquery1DATA_DOCUMENTO.Value := ZQuery1DATA_REGISTRAZIONE.Value;
end;
I obtain this result:
'0000-00-00'
in the column zquery1DATA_DOCUMENTO.Value.
If I change .Value with .AsDateTime the result in zquery1DATA_DOCUMENTO is '30/12/1899'!
This code present in the OnValidate event of the column DATA_DOCUMENTO:
Code: Select all
procedure TForm11.ztbDocTestaDATA_DOCUMENTOValidate(Sender: TField);
begin
if (ZQuery1DATA_DOCUMENTO.AsDateTime > ZQuery1DATA_REGISTRAZIONE.AsDateTime) then
raise Exception.Create('The registration date is more recent than the date of the document!');
end;
seem to work but even if DATA_DOCUMENTO is larger then DATA_REGISTRAZIONE don't raise error!
why those results? What i'm wrong?
Thanks
Re: Column Date and Validating issue
Posted: 27.04.2021, 21:07
by marsupilami
Hello Louis,
I think, it really depends on the value of ZQuery1DATA_REGISTRAZIONE.Value when that happens. What is the value of ZQuery1DATA_REGISTRAZIONE in the database? Do you use firebird or interbase as the protocol?
Best regards,
Jan
Re: Column Date and Validating issue
Posted: 28.04.2021, 13:32
by louis
marsupilami wrote: ↑27.04.2021, 21:07
I think, it really depends on the value of ZQuery1DATA_REGISTRAZIONE.Value when that happens. What is the value of ZQuery1DATA_REGISTRAZIONE in the database?
The value is entered via the keyboard, example: "27/04/2021".
Do you use firebird or interbase as the protocol?
Firebird.
Thanks.
Re: Column Date and Validating issue
Posted: 28.04.2021, 18:50
by louis
Hello,
now I notice that in an OnValidate event, the parameter
Sender contains the new value but the Field still has the old value.
Changing the code from:
Code: Select all
procedure TForm11.ztbDocTestaDATA_DOCUMENTOValidate(Sender: TField);
begin
if (ZQuery1DATA_DOCUMENTO.AsDateTime > ZQuery1DATA_REGISTRAZIONE.AsDateTime) then
raise Exception.Create('The registration date is more recent than the date of the document!');
end;
with
Code: Select all
procedure TForm11.ztbDocTestaDATA_DOCUMENTOValidate(Sender: TField);
begin
if (Sender.Value > ZQuery1DATA_REGISTRAZIONE.AsDateTime) then
raise Exception.Create('The registration date is more recent than the date of the document!');
end;
then works, if the new value entered in the DBControl that contain column ZQuery1DATA_DOCUMENTO is newer of ZQuery1DATA_REGISTRAZIONE.Value raise the exception.
Normally in delphi the column already has the new value inside the OnValidate event while with Zeos it seems that, on the contrary, it doesn't have it yet.
I'm confused
Re: Column Date and Validating issue
Posted: 28.04.2021, 19:00
by louis
I try disabling ZFields (DisableZFields in ZQuery) and generate all new normal persistent fields. I wonder because now the value entered in a DBControl that contain ZQuery1DATA_REGISTRAZIONE is BLANK after OnValidate event even if the value was assignet at Column ZQuery1DATA_DOCUMENTO!
there is a bug?
I'm more confused
Re: Column Date and Validating issue
Posted: 29.04.2021, 19:03
by louis
Hello,
I installed new release 7517 but not work, OnValidate is unusable
Thanks
Re: Column Date and Validating issue
Posted: 30.04.2021, 05:48
by EgonHugeist
Hello Luis,
welcome on V8. Be patient we'll get you in. According your proplem can you create a min example and open a ticket on
https://sourceforge.net/p/zeoslib/tickets/ A bit more code would be nice to resolve the problem.
Re: Column Date and Validating issue
Posted: 30.04.2021, 10:18
by louis
Re: Column Date and Validating issue
Posted: 03.05.2021, 08:19
by louis
Hello,
may be i find the bug?
in a procedure:
Code: Select all
procedure TZAbstractRODataset.SetFieldData(Field: TField; Buffer: {$IFDEF WITH_TVALUEBUFFER}TValueBuffer{$ELSE}Pointer{$ENDIF};
NativeFormat: Boolean);
begin
if Field.DataType in [ftWideString, ftBCD, ftDate, ftTime, ftDateTime] then begin
NativeFormat := True;
if (Field.DataType <> ftWideString) then
FNativeFormatOverloadCalled[Field.DataType] := True;
end;
{$IFNDEF VIRTUALSETFIELDDATA}
inherited SetFieldData(Field, Buffer, NativeFormat);
{$ELSE}
SetFieldData(Field, Buffer);
{$ENDIF}
end;
This assignation
FNativeFormatOverloadCalled[Field.DataType] := True;
not wotks because
FNativeFormatOverloadCalled[Field.DataType] is ever False!
See the Watch list on attached file to see that the debbugger is beyond the line and even if the FieldDataType is ftDate and for this the line FNativeFormatOverloadCalled[Field.DataType] := True; has executed the value of FNativeFormatOverloadCalled[Field.DataType] is not changed and it is still False.
I don't understand why