Skip to content

sql: integer division should return an integer#3308

Closed
madelynnblue wants to merge 1 commit intocockroachdb:masterfrom
madelynnblue:sql-int-division
Closed

sql: integer division should return an integer#3308
madelynnblue wants to merge 1 commit intocockroachdb:masterfrom
madelynnblue:sql-int-division

Conversation

@madelynnblue
Copy link
Copy Markdown
Contributor

Fixes #3271

Review on Reviewable

Comment thread sql/testdata/select
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is exactly why we originally decided against integer division. I'm 👎 on this change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm more on the fence. I think the current behavior is understandable. And I think having integer division result in an integer is also expected given the behavior of other programming languages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer int / int -> float. Truncating the results of division to an integer is understandable only because we're used to it from (some) other languages; it's surprising the first time you run across it and I think it's best to regard it as a historical accident. Also, while postgresql and sqlite truncate integer division, mysql does not, so either decision will break compatibility with something.

@madelynnblue
Copy link
Copy Markdown
Contributor Author

Agreed. Closing.

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.

4 participants