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

Add round, ceil, floor, truncate to the In-Database Column type #6988

Merged
merged 89 commits into from
Jun 30, 2023

Conversation

GregoryTravis
Copy link
Contributor

@GregoryTravis GregoryTravis commented Jun 7, 2023

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@GregoryTravis GregoryTravis changed the title Add .truncate to the In-Database Column type Add round, ceil, floor, truncate to the In-Database Column type Jun 13, 2023
@GregoryTravis
Copy link
Contributor Author

This implementation of round is a generic, "by hand" version using column arithmetic. This approach will only be used in a few cases; most of the time we can use the built-in ROUND() function in both backends.

@GregoryTravis GregoryTravis marked this pull request as ready for review June 13, 2023 19:47
@GregoryTravis GregoryTravis added the CI: Ready to merge This PR is eligible for automatic merge label Jun 27, 2023
@GregoryTravis GregoryTravis removed the CI: Ready to merge This PR is eligible for automatic merge label Jun 28, 2023
if (!special) {
out[i] = doOperation(item);
} else {
String msg = "Value is " + item;
Copy link
Member

Choose a reason for hiding this comment

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

This error message needs to be more user friendly.

Suggested change
String msg = "Value is " + item;
String msg = "The operation " + name + " does not allow " + item + " as input, returning Nothing.";

or sth like that


do_round -1.22222222225 10 . should_equal -1.2222222223
do_round -1.222222222225 11 . should_equal -1.22222222223
do_round -1.2222222222225 12 . should_equal -1.222222222223
do_round -1.22222222222225 13 . should_equal -1.2222222222223
do_round -1.222222222222225 14 . should_equal -1.22222222222223
do_round -1.2222222222222225 15 . should_equal -1.222222222222223
Copy link
Member

Choose a reason for hiding this comment

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

Why are these removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because SQLite fails this test. I could add this one line to the backend-specific test, with different values.

Copy link
Member

Choose a reason for hiding this comment

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

Why does it fail it? Should we be concerned? (if not a big deal, I'm ok with removing it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to backend-specific tests.

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

Looks good, that is a really great piece of work.

I'd just make the message added to the Arithmetic_Error a bit more clear and that's it

@@ -123,7 +123,7 @@ sqlite_specific_spec prefix connection setup =
expected_code = code_template.replace "{Tinfo}" tinfo
t.distinct ["strs"] . to_sql . prepare . should_equal [expected_code, []]

Test.group "[PostgreSQL] math functions" <|
Test.group "[PostgreSQL] math functionsasdfasdf" <|
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Test.group "[PostgreSQL] math functionsasdfasdf" <|
Test.group "[PostgreSQL] math functions" <|

please remove these random letters though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@GregoryTravis GregoryTravis added the CI: Ready to merge This PR is eligible for automatic merge label Jun 29, 2023
@GregoryTravis GregoryTravis linked an issue Jun 29, 2023 that may be closed by this pull request
@mergify mergify bot merged commit 550d146 into develop Jun 30, 2023
@mergify mergify bot deleted the wip/gmt/6886-truncate branch June 30, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add rounding functions to the In-Database Column type
5 participants