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

Andy/div by zero #108

Merged
merged 4 commits into from May 19, 2020
Merged

Andy/div by zero #108

merged 4 commits into from May 19, 2020

Conversation

andy-wm-arthur
Copy link
Contributor

@andy-wm-arthur andy-wm-arthur commented May 19, 2020

This fixes a panic for select 1/0 from dual

MySQL also errors on divide by zero in at least some configs

I can change this to return NULL if that's preferable.

Signed-off-by: Andy Arthur <andy@liquidata.co>
Signed-off-by: Andy Arthur <andy@liquidata.co>
Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

Should follow the default mysql 8.0 behavior, which is to evaluate to NULL.

Also please add an engine test.

Signed-off-by: Andy Arthur <andy@liquidata.co>
@andy-wm-arthur
Copy link
Contributor Author

👌

Signed-off-by: Andy Arthur <andy@liquidata.co>
@andy-wm-arthur andy-wm-arthur merged commit 9d24532 into master May 19, 2020
Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

You should follow up to make the behavior the same for floats and ints.

[]sql.Row{{sql.Null}},
},
{ "SELECT 1.0/0.0 FROM dual",
[]sql.Row{{float64(math.Inf(1))}},
Copy link
Member

Choose a reason for hiding this comment

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

This should be null too. Floats and ints should have the same behavior.

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.

None yet

2 participants