"INT" types on primary elements.

felixkat

Senior Member
There are a number of places, when creating tables or modifying primary keys, where we specify "INT Type"

Code:
'CREATE TABLE IF NOT EXISTS ' . $db->qn($tableName) . ' ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, parent_id INT(11), '

Code:
protected function updatePrimaryKey($fieldName, $autoIncrement, $type = 'int(11)')

Since mysql 8 the 'int' type isn't relevant so

CREATE TABLE mytable (id INT(11) AUTO_INCREMENT PRIMARY KEY

should simply be

CREATE TABLE mytable (id INT AUTO_INCREMENT PRIMARY KEY

Further docs:-

https://stackoverflow.com/questions...s-ignored-in-your-mysql-version-unless-defini

https://stackoverflow.com/questions/3135804/types-in-mysql-bigint20-vs-int20/3135854#3135854

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html


This causes confusing looping messages when adding or saving the "id" field in Fabrik. In this case I imported a CSV and manually tried to create an ID field. At times I was losing the AUTO_INCREMENT, which maybe due to the "ALTER" statement failing due to the INT issues.

Hope that makes sense :D


This will happen every time you save because it can't alter the field to a INT(11)

upload_2023-7-18_14-2-13.png
 
I believe it's from 8 on-wards, I don't know the impact for < 8 versions. I don't mind researching.

Whilst J! requirement is mysql 5.6 version 5.7 is end of life in three months.

The two options would be either set a minimum requirement for Fabrik or "if mysql 8" statements everywhere.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top