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

trim whitespace when casting from string #7854

Closed
jycor opened this issue May 13, 2024 · 0 comments · Fixed by dolthub/go-mysql-server#2497
Closed

trim whitespace when casting from string #7854

jycor opened this issue May 13, 2024 · 0 comments · Fixed by dolthub/go-mysql-server#2497
Labels
correctness We don't return the same result as MySQL good repro Easily reproducible bugs

Comments

@jycor
Copy link
Contributor

jycor commented May 13, 2024

MySQL will trim leading and trailing space(' ') and tab ('\t') characters when casting from a string to a numeric type.

mysql> select cast('\t    123   \t\t' as signed);
+------------------------------------+
| cast('\t    123   \t\t' as signed) |
+------------------------------------+
|                                123 |
+------------------------------------+
1 row in set (0.0004 sec)

Oddly, MySQL will not trim NUL ('\0') or new line ('\n') characters.

mysql> select cast('\0123' as signed);
+-------------------------+
| cast('\0123' as signed) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.0004 sec)
Warning (code 1292): Truncated incorrect INTEGER value: ''
mysql> select cast('\n123' as signed);
+-------------------------+
| cast('\n123' as signed) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.0004 sec)
Warning (code 1292): Truncated incorrect INTEGER value: '
123'

Currently, dolt does not trim any of these.

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

Successfully merging a pull request may close this issue.

1 participant