Recent

Author Topic: IBX 2.3.2+ not setting "Modified"  (Read 1419 times)

Vingadero

  • New Member
  • *
  • Posts: 44
IBX 2.3.2+ not setting "Modified"
« on: October 10, 2019, 05:34:45 pm »
Hello,

I got IBX 2.3.2 version to test and noticed that the "Modified" property is not setting to true after making a change to an TDBEdit component.

Code: Pascal  [Select][+][-]
  1. if DBEditID.Modified then
  2. begin
  3.   ...
  4. end;
  5.  

Also the OldValue and NewValue of TField get always the last value.

Code: Pascal  [Select][+][-]
  1. if DBEditID.Field.OldValue <> DBEditID.Field.NewValue then
  2. begin
  3.  ...
  4. end;

I'm usung Lazarus 2.0.4 and IBX 2.3.2 (tried 2.3.3 from site and got same issues).
The "Modified" works normal with other Datasets components like TMemDataSet

Best Regards

tonyw

  • Sr. Member
  • ****
  • Posts: 321
    • MWA Software
Re: IBX 2.3.2+ not setting "Modified"
« Reply #1 on: October 11, 2019, 11:05:43 am »
TDBEdit is part of the LCL and its behaviour should be the same for all database drivers including IBX.

The "Modified" property is inherited by TDBEdit from TCustomMaskEdit and should only be set when you change the control. It is then reset to false after you have saved the changes in the current row back to the database.

IBX neither sets nor resets the Modified property and the same should be true of any other database driver.

Vingadero

  • New Member
  • *
  • Posts: 44
Re: IBX 2.3.2+ not setting "Modified"
« Reply #2 on: October 11, 2019, 06:28:10 pm »
Hello tonyw, thx for the answer.

Compiling the same project with Lazarus 1.8.2 and IBX 2.0.3 the Modified is set properly...

I'm oppening a bugtracker issue..

Thx in advance

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: IBX 2.3.2+ not setting "Modified"
« Reply #3 on: October 24, 2019, 01:45:01 pm »
I answer late, but for information, it seems to me that the TField.OldValue and TField.NewValue properties are normally "active", only if the cached update is enabled (TDataset.CachedUpdates:= True;)!

In addition, TDataSet.modified is True, as soon as a value is assigned to a TField, even if the same value is reassigned :-\. So, to know if the value is realy different, it is our responsability to store somewhere the original values of the fields. 

And you can also use TDatasource.onDataChange: this event has a parameter that indicates, either the modified TField name (from a TDBEdit like yours :) ), or nil if the whole record is modified (for example, when the record is loaded from the disk towards the db-aware controls).
« Last Edit: October 24, 2019, 01:47:50 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Vingadero

  • New Member
  • *
  • Posts: 44
Re: IBX 2.3.2+ not setting "Modified"
« Reply #4 on: October 24, 2019, 03:05:31 pm »
I answer late, but for information, it seems to me that the TField.OldValue and TField.NewValue properties are normally "active", only if the cached update is enabled (TDataset.CachedUpdates:= True;)!

In addition, TDataSet.modified is True, as soon as a value is assigned to a TField, even if the same value is reassigned :-\. So, to know if the value is realy different, it is our responsability to store somewhere the original values of the fields. 

And you can also use TDatasource.onDataChange: this event has a parameter that indicates, either the modified TField name (from a TDBEdit like yours :) ), or nil if the whole record is modified (for example, when the record is loaded from the disk towards the db-aware controls).

Hello devEric69, thx for you answer

I have a project running on Lazarus 1.8.2 and IBX 2.0.3 with "CachedUpdates:= False" and its works fine.

I have another project on Delphi with IBX too and the Modified/Old/NewValue works fine too..

I have opened an issue at Lazarus Bug tracker with an example using IBX, TDBF and TMemDataSet https://bugs.freepascal.org/view.php?id=36164

Best regards,

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: IBX 2.3.2+ not setting "Modified"
« Reply #5 on: October 24, 2019, 03:32:23 pm »
Hello,

Okay, thanks for the feedback (so, no need, or no more need, to use the TDabase.ApplyUpdates, TQuery.commitUpdates or CancelUpdates or RevertUpdates, etc, in the "briefcase" way, via "CachedUpdates:= True", to use OldValue and NewValue :). I didn't know: it simplifies).

Best regards.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

 

TinyPortal © 2005-2018