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

sql: improve ENUM error message with a hint #52298

Closed
awoods187 opened this issue Aug 3, 2020 · 0 comments · Fixed by #53474
Closed

sql: improve ENUM error message with a hint #52298

awoods187 opened this issue Aug 3, 2020 · 0 comments · Fixed by #53474
Assignees
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@awoods187
Copy link
Contributor

In MySQL, ENUMs are supported with a numeric backed index and you can do something like this:

CREATE TYPE priority AS ENUM ('Low', 'Medium', 'High');
CREATE TABLE tickets (
id INT PRIMARY KEY,
title VARCHAR(255) NOT NULL, 
priority PRIORITY);
INSERT INTO tickets(id,title, priority) VALUES('2','Upgrade Windows OS for all computers', 1);

In PG this isn't supported but has this nice error message:

ERROR:  column "priority" is of type priority but expression is of type integer
LINE 2: VALUES('2','Upgrade Windows OS for all computers', 1);
                                                           ^
HINT:  You will need to rewrite or cast the expression.

In CRDB the message is:

ERROR: value type int doesn't match type priority of column "priority"
SQLSTATE: 42804

We should add this hint or something similar.

@awoods187 awoods187 added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Aug 3, 2020
craig bot pushed a commit that referenced this issue Aug 26, 2020
53474: opt: add hint to column type mismatch on mutation error r=rohany a=rohany

Fixes #52298.

Release justification: low risk, high benefit change to existing
functionality

Release note: None

Co-authored-by: Rohan Yadav <[email protected]>
@craig craig bot closed this as completed in 1d76346 Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants