fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
462 stars 299 forks source link

Cannot change the sex to X #4304

Closed jon48 closed 2 years ago

jon48 commented 2 years ago

Commit 1baf69dec287f195fbbefc3bae3c0b33957a89c3 has added a better support to sex X, but it is actually not possible to edit a person and set its sex to X / "Other".

Here is the error I get when trying to save an individual with sex X

SQLSTATE[01000]: Warning: 1265 Data truncated for column 'i_sex' at row 1 (SQL: insert into `wt_individuals` (`i_id`, `i_file`, `i_rin`, `i_sex`, `i_gedcom`) values (X5, 1, X5, X, 0 @X5@ INDI 1 SEX X 1 NAME John /SexX/ 2 GIVN John 2 SURN SexX 1 BIRT Y 1 DEAT Y 1 CHAN 2 DATE 10 APR 2022 3 TIME 22:05:43 2 _WT_USER jojo48)) …\vendor\illuminate\database\Connection.php:712

Indeed, unless I have missed something, and a DB upgrade has not taken place, the column i_sex is still constrained to the ENUM M, F, U, and X has not been added as an acceptable value.

mysql>  DESCRIBE wt_individuals;
+----------+-------------------+------+-----+---------+-------+
| Field    | Type              | Null | Key | Default | Extra |
+----------+-------------------+------+-----+---------+-------+
| i_id     | varchar(20)       | NO   | PRI | NULL    |       |
| i_file   | int(11)           | NO   | PRI | NULL    |       |
| i_rin    | varchar(20)       | NO   |     | NULL    |       |
| i_sex    | enum('U','M','F') | NO   |     | NULL    |       |
| i_gedcom | longtext          | NO   |     | NULL    |       |
+----------+-------------------+------+-----+---------+-------+
fisharebest commented 2 years ago

doctrine/dbal is well known for its inability to modify tables containing ENUM fields.

So, we either

However, there is still lots of code that assumes M/F/U and will fail on X.

jon48 commented 2 years ago

Yes, that is why I did not suggest a PR for that one, as I did not know how you preferred to handle it. I was going to submit a PR for the other display issues, but you have been quicker than me 😃