ENUM is treated differently in MySQL and MariaDB

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
waheed
Posts: 20
Joined: Mon 02 Nov 2009 19:47
Location: Kuwait

ENUM is treated differently in MySQL and MariaDB

Post by waheed » Wed 07 Oct 2015 03:30

When you add fields to the field editor (you know, right click on Query component and select Fields Editor, then add all) Field definition is different between MySQL and MariaDB for EMUM columns.
I'm not talking about straight field mapping of ENUMs, but I'm talking about when you want the integer value of the ENUM, so you add 0 to it.
Here is the table creation

Code: Select all

CREATE TABLE `enumtest` (
	`enumfield` ENUM('Y','N') NULL DEFAULT NULL
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM;
and here is the select statement:

Code: Select all

select enumfield, (enumfield+0) as enumfieldI from enumtest
The problem is in mapping (enumfield+0)
in mysql it is mapped to Float, and in MariaDB it is mapped to Largeint

I think this is a BUG!

NOTE 1: I know many are against using ENUM all together. But till I have time to change, I need this fixed.
NOTE 2: I know I can do field mapping and force both of them to integer.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: ENUM is treated differently in MySQL and MariaDB

Post by ViktorV » Wed 07 Oct 2015 14:37

MariaDB returns the MYSQL_TYPE_LONGLONG type for the specified column. And MySQL server returns MYSQL_TYPE_DOUBLE. And using this data, we create corresponding fields. If you want to create an Integer field for this column, you should use data type mapping.

waheed
Posts: 20
Joined: Mon 02 Nov 2009 19:47
Location: Kuwait

Re: ENUM is treated differently in MySQL and MariaDB

Post by waheed » Wed 07 Oct 2015 14:43

Thanks, that is what I did "Field Mapping".
Therefore MariaDB does NOT EQUAL MySQL.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: ENUM is treated differently in MySQL and MariaDB

Post by ViktorV » Wed 07 Oct 2015 14:52

If you have any questions during using our products, please don't hesitate to contact us - and we will try to help you solve them.

Post Reply