Page 1 of 1

TVirtualQuery Bug With NULL TDateTime Fields

Posted: Thu 24 Aug 2017 22:13
by Aggie85
Howdy!

If a dataset's TDate/TTime fields are set NULL fields and a TVirtualQuery statement is executed against the dataset, the untouched TDate/TTime NULL fields are set to 0 instead of setting the field's Variant value as NULL (Null()). Setting a TDate/TTime field to just 0 when it was a NULL value from the underlying source dataset causes the TField's IsNull property to return false instead of true and values in data-aware controls are shown as 12/30/1899 (Delphi NULL default value).

All the best,

Aggie85

Re: TVirtualQuery Bug With NULL TDateTime Fields

Posted: Mon 28 Aug 2017 08:55
by MaximG
Thank you for the message. Please explain which query you are executing when you get the described behavior. For this, compose and send us a small sample using the e-support form (https://www.devart.com - the "Support"\"Request Support" menu).

Re: TVirtualQuery Bug With NULL TDateTime Fields

Posted: Fri 01 Sep 2017 16:53
by Aggie85
Howdy Maxim!

I will put together a small demo to illustrate the bug.

Since I had to get my beta out, I just wrote my own wrapper class around TVirtualQuery that essentially replaced all source data sets BeforePost() events with a local one that checks all TDate/TTime fields with a value of 0. If the values are 0, I set the value to Null() which keeps the field's IsNull() method to True and then I call the previous BeforeEvent() for the dataset if there is one.

My solution adds very little overhead and allows me to fix these type of things quickly with no delay.

Have a great weekend,

Aggie85