No Code Attached Yet
avatar brbrbr
brbrbr
17 Sep 2025

given a sql update like

ALTER TABLE #__table CHANGE adddate adddate datetime NOT NULL DEFAULT CURRENT_TIMESTAMP()

and the adddate column has CURRENT_TIMESTAMP() as default.

Expected result

Maintenance: Database reports no problems

Actual result

Maintenance: Database reports a problem

libraries/src/Schema/ChangeItem/MysqlChangeItem.php generates a checkQuery

generates

SHOW COLUMNS IN #__table WHERE field = 'adddate' AND UPPER(type) = 'DATETIME' AND default = current_timestamp()

should be

SHOW COLUMNS IN #__table WHERE field = 'adddate' AND UPPER(type) = 'DATETIME' AND default = 'current_timestamp()'

same for 'current_timestamp'

System information (as much as possible)

11.7.2-MariaDB-ubu2404
J53+ not checked in older versions

avatar brbrbr brbrbr - open - 17 Sep 2025
avatar joomla-cms-bot joomla-cms-bot - change - 17 Sep 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Sep 2025
avatar richard67
richard67 - comment - 18 Sep 2025

The ChangeItem classes in general do not support expressions as default values. It could be probably fixed for a few common expressions like e.g. current_timestamp() but not for all possible expressions as the expression is stored in a modified way in the information_schema, e.g. upper or lower case changed, and MySQL and MariaDB behave differently regarding that.

avatar brbrbr
brbrbr - comment - 18 Sep 2025

Wouldn't it be sufficient to always quote the default value in the SHOW COLUMNS?

avatar richard67
richard67 - comment - 18 Sep 2025

Wouldn't it be sufficient to always quote the default value in the SHOW COLUMNS?

@brbrbr Not sure if that would be suitable for numeric values (integer or float).

Add a Comment

Login with GitHub to post a comment