Page 1 of 1
Boolean bug
Posted: Thu 05 May 2005 13:43
by ben
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).
Posted: Thu 05 May 2005 14:09
by ben
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.
Posted: Fri 06 May 2005 07:43
by Ikar
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.
Posted: Fri 06 May 2005 09:35
by ben
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.
Posted: Fri 06 May 2005 13:59
by Ikar
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.