Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.1.13 #143

Merged
merged 3 commits into from
Aug 2, 2024
Merged

v2.1.13 #143

merged 3 commits into from
Aug 2, 2024

Conversation

aristath
Copy link
Member

@aristath aristath commented Aug 2, 2024

Version 2.1.13

jeroenpf and others added 3 commits July 30, 2024 11:27
This PR addresses an issue where the output of `show create table` is
incorrect when the table has a `NULL` column without a default value.

Here is an example:

```sql

-- Original MySQL query

CREATE TABLE `wp_usermeta` (
	`umeta_id` bigint(20) unsigned NOT NULL auto_increment,
	`user_id` bigint(20) unsigned NOT NULL default '0',
	`meta_key` varchar(255) default NULL,
	`meta_value` longtext,
	PRIMARY KEY  (`umeta_id`),
	KEY `user_id` (`user_id`),
	KEY `meta_key` (`meta_key`(191))
)

-- Output by `SHOW CREATE TABLE` via SQLite plugin

CREATE TABLE `wp_usermeta` (
	`umeta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
	`user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
	`meta_key` varchar(255) DEFAULT NULL,
	`meta_value` longtext DEFAULT , -- Default value missing
	PRIMARY KEY (`umeta_id`),
	KEY `meta_key` (`meta_key`),
	KEY `user_id` (`user_id`)
);

-- After this fix

CREATE TABLE `wp_usermeta` (
	`umeta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
	`user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
	`meta_key` varchar(255) DEFAULT NULL,
	`meta_value` longtext,
	PRIMARY KEY (`umeta_id`),
	KEY `meta_key` (`meta_key`),
	KEY `user_id` (`user_id`)
);
```
This PR addresses an issue where the ALTER TABLE CHANGE with skipped
COLUMNS keyword was ignored.

We supporter query

```sql
-- Processed correctly
ALTER TABLE _tmp_table CHANGE COLUMN name firstname varchar(50) NOT NULL default 'mark';

-- Was ignored
ALTER TABLE _tmp_table CHANGE name firstname varchar(50) NOT NULL default 'mark';
```
This PR fixes the issue by adding support for optional COLUMN in the
ALTER TABLE CHANGE query
@aristath aristath merged commit d913e6b into main Aug 2, 2024
9 checks passed
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