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

Fix formatting issue in CAST MONEY to CHAR/VARCHAR #3367

Conversation

rishabhtanwar29
Copy link
Contributor

@rishabhtanwar29 rishabhtanwar29 commented Jan 7, 2025

Description

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar [email protected]

Test Scenarios Covered

  • Use case based -
    test_conv_money_to_varchar-vu-*

  • Boundary conditions -

  • Arbitrary inputs -

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Rishabh Tanwar <[email protected]>
Signed-off-by: Rishabh Tanwar <[email protected]>
Signed-off-by: Rishabh Tanwar <[email protected]>
Signed-off-by: Rishabh Tanwar <[email protected]>
Signed-off-by: Rishabh Tanwar <[email protected]>
Signed-off-by: Rishabh Tanwar <[email protected]>
Signed-off-by: Rishabh Tanwar <[email protected]>
@rishabhtanwar29 rishabhtanwar29 changed the title Fix formatting issue in CAST MONEY to VARCHAR Fix formatting issue in CAST MONEY to CHAR/VARCHAR Jan 8, 2025
@coveralls
Copy link
Collaborator

coveralls commented Jan 8, 2025

Pull Request Test Coverage Report for Build 12705529749

Details

  • 43 of 48 (89.58%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 74.961%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contrib/babelfishpg_money/fixeddecimal.c 11 12 91.67%
contrib/babelfishpg_common/src/varchar.c 32 36 88.89%
Totals Coverage Status
Change from base Build 12696145122: 0.01%
Covered Lines: 46900
Relevant Lines: 62566

💛 - Coveralls

@KushaalShroff KushaalShroff self-requested a review January 8, 2025 11:46
contrib/babelfishpg_common/src/varchar.c Outdated Show resolved Hide resolved
contrib/babelfishpg_common/src/varchar.c Outdated Show resolved Hide resolved
contrib/babelfishpg_common/src/varchar.c Show resolved Hide resolved
@rishabhtanwar29 rishabhtanwar29 merged commit 690cd99 into babelfish-for-postgresql:BABEL_5_X_DEV Jan 13, 2025
46 checks passed
@rishabhtanwar29 rishabhtanwar29 deleted the jira-babel-5478 branch January 13, 2025 07:57
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 13, 2025
…tgresql#3367)

While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit that referenced this pull request Jan 14, 2025
While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
rishabhtanwar29 added a commit that referenced this pull request Jan 14, 2025
While CASTing money/smallmoney to (N)VARCHAR/(N)CHAR, the value get rounded
to 4 decimal places instead of 2. Fixed this by implementing CASTs from money to
CHAR/VARCHAR datatype which rounds off input money value to 2 decimal places and
converts it to string.

Additionally, while CASTing money values to (N)CHAR, the resultant string gets left padded
instead of usual right padding. This commit also fixes this issue.

Task: BABEL-5478
Signed-off-by: Rishabh Tanwar <[email protected]>
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.

6 participants