Boolean bug

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ben
Posts: 119
Joined: Wed 17 Nov 2004 19:48

Boolean bug

Post by ben » Thu 05 May 2005 13:43

there is a field that is ENUM('Y','N')

I call with my code

Query1.ParamByName('payed').AsBoolean := true;

it works, it sets 'Y'.

but if I say

Query1.ParamByName('payed').AsBoolean := false;

it doesnt add 'N', it leaves it empty ''

Then I added default value to the field 'N'. Nothing, still '' (empty).

ben
Posts: 119
Joined: Wed 17 Nov 2004 19:48

Post by ben » Thu 05 May 2005 14:09

Also, i cant make it Tinyint(1) because the database is not mine. I just did a small project that works in existing system. So I need to work with ENUM, the way all mysql developers in the world work.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 06 May 2005 07:43

MySQL doesn't support quick methods of differentiation ENUM and CHAR on client side.

Use

Query1.ParamByName('payed').AsString := 'Y'; // 'N'

to get expected result.

ben
Posts: 119
Joined: Wed 17 Nov 2004 19:48

Post by ben » Fri 06 May 2005 09:35

The right is to use ENUM('Y','N') while most of components outside support that way. Microolap's MySQL Components support the ENUM directly using AsBoolean. ZeosLib the same. At last, DevExpress QuantumGrid can read only ENUM(Y,N) to display checkboxes not Tinyint(1).

So, i believe you should support both of them.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 06 May 2005 13:59

According to the current MySQL standards (http://dev.mysql.com/doc/mysql/en/boolean-values.html)boolean values must be written as '0' and '1'.

As to DevExpress QuantumGrid most likely on calling TBooleanField CheckBox will be displayed not depending on declaration of the field at the server.

Post Reply