View Issue Details

IDProjectCategoryView StatusLast Update
0030954FPCDatabasepublic2018-05-18 13:04
ReporterVladimir KAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platform64OSWindowsOS Version10
Product Version3.0.1Product BuildLazarus 1.7 
Target Version3.2.0Fixed in Version3.1.1 
Summary0030954: Bug with fkCalculated fields
DescriptionFirst issue in fields.inc that leads to wrong FDefaultFields value:

procedure TFields.Changed;
begin
  if (FDataSet <> nil) and not (csDestroying in FDataSet.ComponentState) and FDataset.Active then
    FDataSet.DataEvent(deFieldListChange, 0);

FDataset.Active (absent in Delphi 6-7) check prevents call of FDataSet.DataEvent while DataSet not active yet, like

  Query := CreateDataSet('query', 'Select ' + FieldName + ' From ' + TableName, Null) as TCustomDADataSet;
  try
    Query.Prepare;
    Query.FieldDefs.Add('MyCalcField', ftInteger, 0, False);
    for i := 0 to Query.FieldDefs.Count - 1 do
    begin
      FieldDef := Query.FieldDefs.Items[i];
      Field := FieldDef.CreateField(Query); <- from here through Result.Dataset:=TFieldDefs(Collection).Dataset
      if Field.FieldName = 'MyCalcField' then
      Field.FieldKind := fkCalculated;
    end;
    Query.OnCalcFields := OnCalcFields;
    try
      Query.Open;

Another issue:

procedure TDataSet.DoInternalOpen;
begin
  FDefaultFields := FieldCount = 0; <- missing in FPC, exists in Delphi 7
  InternalOpen;
Steps To ReproduceUniDAC ASE Direct components used.
Additional InformationFirst fix (fields.inc):

procedure TFields.Changed;
begin
  if (FDataSet <> nil) and not (csDestroying in FDataSet.ComponentState) then
    FDataSet.DataEvent(deFieldListChange, 0);

Second (dataset.inc):

procedure TDataSet.DoInternalOpen;
begin
  FDefaultFields := FieldCount = 0;
  InternalOpen;
TagsNo tags attached.
Fixed in Revision39022
FPCOldBugId
FPCTarget
Attached Files

Activities

Michael Van Canneyt

2016-11-27 12:48

administrator   ~0096291

I've fixed the issue with the FDataset.Active.

The other one I didn't fix:
FDefaultFields is initialized before DoInternalOpen is called, which should be the same as when it is called inside doInternalOpen.

Also doInternalOpen is private, so you are not supposed to know about what it does or does not do.

However, if you can show a case where the behaviour of FPC and Delphi differs because of this, please report it and we'll look at it (but in a different bug, please).

LacaK

2016-12-28 18:21

developer   ~0097127

I have reopened because some tests are broken. For example:

<Failure>
  <Message>TTestDBBasics.TestMove: "" expected: <deUpdateState:0;> but was: <deFieldListChange:0;deFieldListChange:0;deUpdateState:0;></Message>
  <ExceptionClass>EAssertionFailedError</ExceptionClass>
  <ExceptionMessage>"" expected: <deUpdateState:0;> but was: <deFieldListChange:0;deFieldListChange:0;deUpdateState:0;></ExceptionMessage>
</Failure>
<Failure>
  <Message>TTestDBBasics.TestdeFieldListChange: "" expected: <deUpdateState:0;deFieldListChange:0;> but was: <deFieldListChange:0;deFieldListChange:0;deUpdateState:0;deFieldListChange:0;></Message>
  <ExceptionClass>EAssertionFailedError</ExceptionClass>
  <ExceptionMessage>"" expected: <deUpdateState:0;deFieldListChange:0;> but was: <deFieldListChange:0;deFieldListChange:0;deUpdateState:0;deFieldListChange:0;></ExceptionMessage>
</Failure>
<Failure>
  <Message>TTestCursorDBBasics.TestBug7007: "" expected: <deUpdateState:0;> but was: <deFieldListChange:0;deFieldListChange:0;deUpdateState:0;></Message>
  <ExceptionClass>EAssertionFailedError</ExceptionClass>
  <ExceptionMessage>"" expected: <deUpdateState:0;> but was: <deFieldListChange:0;deFieldListChange:0;deUpdateState:0;></ExceptionMessage>
</Failure>

(I do not looked deeper into problem. If tests are wrong then please fix tests.)

Michael Van Canneyt

2018-05-18 12:57

administrator   ~0108400

Fixed event problems using patch of Laco. Please test and close if OK.

Issue History

Date Modified Username Field Change
2016-11-18 17:20 Vladimir K New Issue
2016-11-19 13:22 Michael Van Canneyt Assigned To => Michael Van Canneyt
2016-11-19 13:22 Michael Van Canneyt Status new => assigned
2016-11-27 12:48 Michael Van Canneyt Fixed in Revision => 34980
2016-11-27 12:48 Michael Van Canneyt Note Added: 0096291
2016-11-27 12:48 Michael Van Canneyt Status assigned => resolved
2016-11-27 12:48 Michael Van Canneyt Fixed in Version => 3.1.1
2016-11-27 12:48 Michael Van Canneyt Resolution open => fixed
2016-11-27 12:48 Michael Van Canneyt Target Version => 3.2.0
2016-12-28 18:21 LacaK Note Added: 0097127
2016-12-28 18:21 LacaK Status resolved => feedback
2016-12-28 18:21 LacaK Resolution fixed => reopened
2018-05-18 12:57 Michael Van Canneyt Fixed in Revision 34980 => 39022
2018-05-18 12:57 Michael Van Canneyt Note Added: 0108400
2018-05-18 12:57 Michael Van Canneyt Status feedback => resolved
2018-05-18 12:57 Michael Van Canneyt Resolution reopened => fixed