-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inconsistent formatting issue in convert function when converting…
… from money to varchar (#3337) (#3361) Description Currently when converting from money to varchar using convert function with different style values, the result is inconsistent with the formatting. This PR will address this issue by updating the logic to handle these edge cases. The issues that will get addressed in this PR are as follows Extra space is getting added in the beginning of the result when style parameter is 0 or 2. When input is 0, then 0 is missing before decimal in the result for style 0 and 2. Also for style 1 the result has $ before decimal instead of 0. For example, when converting value 0 with money datatype to varchar datatype For style 0, result is .00 For style 1, result is $.00 For style 2, result is .0000 When style is 2, and the input has more than 2 digits after decimal, then the result is getting rounded upto 2 digits after decimal, which ideally should be rounded upto 4 digits. Issues Resolved BABEL-5462 Authored-by: Rohit Bhagat [email protected] Signed-off-by: Rohit Bhagat [email protected]
- Loading branch information
1 parent
fbe64c3
commit 6cd7bc0
Showing
41 changed files
with
939 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/JDBC/expected/test_conv_money_to_varchar-vu-cleanup.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
DROP VIEW test_conv_string_to_date_v1 | ||
GO | ||
|
||
DROP PROCEDURE test_conv_string_to_date_p1 | ||
GO | ||
|
||
DROP FUNCTION test_conv_string_to_date_f1 | ||
GO | ||
|
||
DROP TABLE test_conv_money_to_varchar_t1 | ||
GO |
39 changes: 39 additions & 0 deletions
39
test/JDBC/expected/test_conv_money_to_varchar-vu-prepare.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
CREATE TABLE test_conv_money_to_varchar_t1(val money) | ||
GO | ||
|
||
INSERT INTO test_conv_money_to_varchar_t1 VALUES (1234), (0), (123.12), (0.12456) | ||
GO | ||
~~ROW COUNT: 4~~ | ||
|
||
|
||
CREATE VIEW test_conv_string_to_date_v1 as ( | ||
SELECT val, | ||
val_convert = '$' + CONVERT(VARCHAR, val) , | ||
val_convert_style_0 = '$' + CONVERT(VARCHAR, val, 0), | ||
val_convert_style_1 = '$' + CONVERT(VARCHAR, val, 1), | ||
val_convert_style_2 = '$' + CONVERT(VARCHAR, val, 2) | ||
FROM test_conv_money_to_varchar_t1 | ||
); | ||
GO | ||
|
||
CREATE PROCEDURE test_conv_string_to_date_p1 as ( | ||
SELECT val, | ||
val_convert = '$' + CONVERT(VARCHAR, val) , | ||
val_convert_style_0 = '$' + CONVERT(VARCHAR, val, 0), | ||
val_convert_style_1 = '$' + CONVERT(VARCHAR, val, 1), | ||
val_convert_style_2 = '$' + CONVERT(VARCHAR, val, 2) | ||
FROM test_conv_money_to_varchar_t1 | ||
); | ||
GO | ||
|
||
CREATE FUNCTION test_conv_string_to_date_f1() | ||
RETURNS TABLE AS | ||
RETURN ( | ||
SELECT val, | ||
val_convert = '$' + CONVERT(VARCHAR, val) , | ||
val_convert_style_0 = '$' + CONVERT(VARCHAR, val, 0), | ||
val_convert_style_1 = '$' + CONVERT(VARCHAR, val, 1), | ||
val_convert_style_2 = '$' + CONVERT(VARCHAR, val, 2) | ||
FROM test_conv_money_to_varchar_t1 | ||
); | ||
GO |
Oops, something went wrong.