Map MariaDb/MySql TINYINT(1) to TZBooleanField

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
abonic
Junior Boarder
Junior Boarder
Posts: 28
Joined: 25.11.2016, 17:00

Map MariaDb/MySql TINYINT(1) to TZBooleanField

Post by abonic »

When using the Boolean type in the sql create table statement, MariaDb (and I assume MySql) will produce a TINYINT(1) type. ZEOS has a MySQL_FieldType_Bit_1_IsBoolean option that allows BIT(1) to be mapped to a TZBooleanField, but nothing similar for TINYINT(1), which would be more useful these days.

Another thing, this is the description for the option MySQL_FieldType_Bit_1_IsBoolean: "Treat fieldtype BIT(1) as Boolean instead of ENUM('Y','N'), Default since 7.3". The mapping won't work if I don't add that option, so I don't understand what this "Default since 7.3" means.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Map MariaDb/MySql TINYINT(1) to TZBooleanField

Post by marsupilami »

Hello abonic,
abonic wrote: 02.08.2024, 08:57 When using the Boolean type in the sql create table statement, MariaDb (and I assume MySql) will produce a TINYINT(1) type. ZEOS has a MySQL_FieldType_Bit_1_IsBoolean option that allows BIT(1) to be mapped to a TZBooleanField, but nothing similar for TINYINT(1), which would be more useful these days.
I will add that as a feature request in the bug tracker.
abonic wrote: 02.08.2024, 08:57 Another thing, this is the description for the option MySQL_FieldType_Bit_1_IsBoolean: "Treat fieldtype BIT(1) as Boolean instead of ENUM('Y','N'), Default since 7.3". The mapping won't work if I don't add that option, so I don't understand what this "Default since 7.3" means.
Zeos 8.0.0 has problems detecting modern libmaridab versions. This is because MariaDB decided to break versioning of libmariadb. Feature detection in Zeos 8.0.0 works well for libmaridb versioins 10. Newer libmariadb versions start with 3 as their verion number which breaks feature detection in Zeos. This has been adressed in the current 8.0-patches branch. We are going to release a new stable version soon.

Best regards,

Jan
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Map MariaDb/MySql TINYINT(1) to TZBooleanField

Post by marsupilami »

I created a feature request for this: https://sourceforge.net/p/zeoslib/internaltickets/51/.

We could decide to treat both field types (TINYINT(1) and BIT(1)) as boolean? Opinions?
Note: Adding this by default would be a breaking change.
abonic
Junior Boarder
Junior Boarder
Posts: 28
Joined: 25.11.2016, 17:00

Re: Map MariaDb/MySql TINYINT(1) to TZBooleanField

Post by abonic »

MySQL since version 8.0 has also defined BOOLEAN and BOOL as synonyms for TINYINT(1), so both databases are compatible in this regard.

I'm fine with any solution that will map TINYINT(1) to TZBooleanField, but it's possible someone uses TINYINT(1) as an integer. If that is indeed the case, then it would not be wise to make it a default option. The solution that guarantees the least problems is to introduce the MySQL_FieldType_TinyInt_1_IsBoolean property. Maybe even at the Dataset level, but that's probably a step too far.
Post Reply