babelfish_extensions icon indicating copy to clipboard operation
babelfish_extensions copied to clipboard

[DO NOT MERGE] Added wrapper for UPPER() and LOWER() functions for CHAR and NCHAR to handle padding for shorter strings

Open Anikait143 opened this issue 1 year ago • 1 comments

Description

1. Issues

  • UPPER() and LOWER() functions for CHAR or NCHAR types compared to a string shorter than definition cause condition to fail.
  • String functions do not handle chinese characters for NVARCHAR type when collation is not used in UPPER() and LOWER() functions

2. Changes made to fix the issues

  • Added wrapper function handling for UPPER() and LOWER() functions to handle CHAR and NCHAR as VARCHAR and NVARCHAR respectively.
# Input
DECLARE @class NCHAR(2) = N'H'
SELECT '[' + @class + ']' WHERE upper(@class) = N'H'
SELECT '[' + @class + ']' WHERE lower(@class) = N'h'
# previous output (wrong output)               
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

(0 rows affected)
# current output (correct output)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[H ]                                                                                                                                                                                                                                                            

(1 rows affected)
# previous output (wrong output)
1> declare @string1 nvarchar(30) = N'比尔·拉';
2> select UPPER(@string1)
3> GO
@string1                      
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
??·?  
# current output (correct output)
1> declare @string1 nvarchar(30) = N'比尔·拉';
2> select UPPER(@string1)
3> GO
@string1                      
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
比尔·拉
  • Added Test Cases for these issues

Task: BABEL- 3395 Authored-by: Anikait Agrawal [email protected] Signed-off-by: Anikait Agrawal [email protected]

Test Scenarios Covered

  • Use case based - BABEL-3395-vu-*

  • Boundary conditions -

  • Arbitrary inputs -

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Memory tests -

  • Client tests -

Check List

  • [x] 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.

Anikait143 avatar Apr 24 '24 08:04 Anikait143

Pull Request Test Coverage Report for Build 8813386609

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 72.937%

Totals Coverage Status
Change from base Build 8812947782: 0.0%
Covered Lines: 41151
Relevant Lines: 56420

💛 - Coveralls

coveralls avatar Apr 24 '24 08:04 coveralls