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

Allow UNIQUE and PRIMARY KEY to be specified on the same column #305

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

fulghum
Copy link

@fulghum fulghum commented Jan 23, 2024

Related to: dolthub/dolt#7395

@fulghum fulghum requested a review from zachmu as a code owner January 23, 2024 19:32
Copy link

@jycor jycor left a comment

Choose a reason for hiding this comment

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

LGTM!

It seems like MySQL also allows multiple unique keys to be defined over the same column(s), and just ignores the duplicates
Not sure if it's worth adding in this PR though.

mysql> create table t (id int unique key unique key);
Query OK, 0 rows affected (0.0259 sec)

mysql> show create table t;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                            |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `id` int DEFAULT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.0012 sec)

@fulghum
Copy link
Author

fulghum commented Jan 23, 2024

whoa... good find on the duplicate key options! Very weird that MySQL allows that. I'll go ahead and add support for that while I'm in here since it's only a couple more lines of code and some new test statements. Thank you!

@fulghum fulghum merged commit b7f758f into main Jan 23, 2024
4 checks passed
@fulghum fulghum deleted the fulghum/serial branch January 23, 2024 20:29
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