Skip to content

Change column default string value#20244

Draft
M393 wants to merge 5 commits intophpmyadmin:QA_5_2from
M393:change-column-default-string-value
Draft

Change column default string value#20244
M393 wants to merge 5 commits intophpmyadmin:QA_5_2from
M393:change-column-default-string-value

Conversation

@M393
Copy link
Copy Markdown
Contributor

@M393 M393 commented Mar 17, 2026

Fixes the column editing problem from #16801.
The default value for text columns is still displayed in quotes in the table structure page.

Example table, when editing, both column Default values should be As defined: with empty string value

CREATE TABLE `empty_default` (
`c1` TINYTEXT NOT NULL DEFAULT '', 
`c2` VARCHAR(77) NOT NULL DEFAULT '' 
) ENGINE = InnoDB;

The problem with the missing default value when it is an empty string was introduces in 8929288

The problem with quotes not being removed when editing a text column is probably even older, the value was assigned to the wrong property.

@M393 M393 marked this pull request as draft March 19, 2026 17:11
@M393
Copy link
Copy Markdown
Contributor Author

M393 commented Mar 19, 2026

There is some ambiguity here with expressions and literals, probably best to add a new expression type to the select input.

  • None
  • As defined:
  • Expression:
  • NULL
  • CURRENT_TIMESTAMP

There are quite a few differences between the different MySQL/MariaDB versions for this, makes it rather difficult to implement.

@M393 M393 force-pushed the change-column-default-string-value branch from 5ae3ff2 to f719f5e Compare March 19, 2026 18:36
Comment on lines +536 to +537
mb_substr($columnMeta['Default'], 0, 1) === "'" &&
mb_substr($columnMeta['Default'], -1) === "'"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str_starts_with and ends_with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires PHP 8, or is a compat lib used?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's easy to check. You can grep the repo for that name and see if it's already in use. You can also check in composer.json whether symfony/polyfill-php80 is required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symfony/polyfill-php80 is required in composer.json, so it is available.

M393 added 5 commits March 23, 2026 09:27
null in a switch also matches empty string.

Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
For text type columns the value is quoted. The unquoted value was
written to the wrong property in $columnMeta. Has to be 'DefaultValue'
instead of 'Default'.

Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
@M393 M393 force-pushed the change-column-default-string-value branch from f719f5e to 7e3263f Compare March 23, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants