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

Support CREATE TABLE unique keys with no key name #130

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

akirk
Copy link
Member

@akirk akirk commented Jul 18, 2024

In a table like

CREATE TABLE `test` (
	`id` INT,
	`name` VARCHAR(255),
	`other` VARCHAR(255),
	PRIMARY KEY (id),
	UNIQUE KEY (name)
)

the internal name for the unique key would be ( because typically a key would be defined with

UNIQUE KEY `name` (name)

Usually this wrong key name is not a problem unless a INSERT .. ON DUPLICATE KEY statement is used where the resulting ON CONFLICT( "keyname" ) would be transformed to ON CONFLICT( "" ) which then fails.

To fix this, this now derives a key name in case it is omitted..

cc @costasovo

Copy link
Member

@brandonpayton brandonpayton left a comment

Choose a reason for hiding this comment

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

This looks good, and the updated tests pass. Thanks, @akirk!

@brandonpayton brandonpayton merged commit d074dec into WordPress:main Jul 18, 2024
8 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.

2 participants