Problem with TMyTable and boolean field

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ads42
Posts: 36
Joined: Tue 08 Jan 2013 14:13

Problem with TMyTable and boolean field

Post by ads42 » Mon 03 Feb 2014 10:02

Hi,
I have a boolean field declared like this :
active_client tinyint(1) UNSIGNED DEFAULT '255'

When trying to fill a TMyTable I do
DestTable.FieldByName(FieldName).value := FieldValue;
here FieldValue is 0 or 255, but I get 0 or 1 when looking at the table.
Any idea ?
Regards

PavloP
Devart Team
Posts: 149
Joined: Fri 24 Jan 2014 12:33

Re: Problem with TMyTable and boolean field

Post by PavloP » Tue 04 Feb 2014 15:57

By default, tinyint(1) MySQL server field is mapped to a TBooleanField. This field works with boolean values, and therefore all values are converted to 0 and 1. To work with integer values, set the TMyTable.Options.EnableBoolean property to False. At this, the field will be mapped to TSmallintField.

More details about the TMyTable.Options.EnableBoolean property can be seen in the MyDAC documentation:
http://www.devart.com/mydac/docs/index. ... oolean.htm

Post Reply