Page 1 of 1
Map MariaDb/MySql TINYINT(1) to TZBooleanField
Posted: 02.08.2024, 08:57
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.
Re: Map MariaDb/MySql TINYINT(1) to TZBooleanField
Posted: 08.08.2024, 07:57
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
Re: Map MariaDb/MySql TINYINT(1) to TZBooleanField
Posted: 08.08.2024, 08:10
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.
Re: Map MariaDb/MySql TINYINT(1) to TZBooleanField
Posted: 10.08.2024, 08:56
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.