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

enum conversion type has unexpected results #8598

Open
jycor opened this issue Nov 25, 2024 · 0 comments
Open

enum conversion type has unexpected results #8598

jycor opened this issue Nov 25, 2024 · 0 comments
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue good repro Easily reproducible bugs

Comments

@jycor
Copy link
Contributor

jycor commented Nov 25, 2024

Depending on the conversion, we need to treat ENUMs as either ints or strings.

MySQL:

create table t (i int primary key, e enum('abc', 'def', 'ghi'));
insert into t values (1, 'abc'), (2, 'def'), (3, 'ghi');
select i, cast(e as char) from t;
+---+-----------------+
| i | cast(e as char) |
+---+-----------------+
| 1 | abc             |
| 2 | def             |
| 3 | ghi             |
+---+-----------------+
3 rows in set (0.0005 sec)

select i, cast(e as signed) from t;
+---+-------------------+
| i | cast(e as signed) |
+---+-------------------+
| 1 |                 1 |
| 2 |                 2 |
| 3 |                 3 |
+---+-------------------+
3 rows in set (0.0004 sec)

Dolt:

select i, cast(e as char) from t;
+---+-----------------+
| i | cast(e as char) |
+---+-----------------+
| 1 | 1               |
| 2 | 2               |
| 3 | 3               |
+---+-----------------+
3 rows in set (0.00 sec)

select i, cast(e as signed) from t;
+---+-------------------+
| i | cast(e as signed) |
+---+-------------------+
| 1 |                 1 |
| 2 |                 2 |
| 3 |                 3 |
+---+-------------------+
3 rows in set (0.0004 sec)

This also impacts CASE statements (and probably many others), as the resulting enum is converted to a string, but comes out as an int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue good repro Easily reproducible bugs
Projects
None yet
Development

No branches or pull requests

2 participants