babelfish-for-postgresql / babelfish_extensions

Babelfish for PostgreSQL provides the capability for PostgreSQL to work with applications written for Microsoft SQL Server. Babelfish understands the SQL Server wire-protocol and T-SQL, the Microsoft SQL Server query and procedural language, so you don’t have to switch database drivers or rewrite all of your application queries.
https://babelfishpg.org/
Apache License 2.0
265 stars 88 forks source link

Fix differences in T-SQL COALESCE function while calling the function with variables and constants together #2635

Closed basasairohan closed 1 month ago

basasairohan commented 1 month ago

Description

This commit will fix the following issues with T-SQL COALESCE function :

  1. When the arguments contain the mix of variables and constants as shown below, the below query should return 4 as it is the first non-null value. But BBF throws error as we try to evaluate the constant ('dfidhfgi') at the compile time in this case.
    DECLARE @abc int = 4 ;
    select COALESCE(@abc, 'dfidhfgi')
  2. When the arguments are of varbinary and nvarchar type, BBF throws error as we have defined the CAST between varbinary and nvarchar as ASSIGNMENT, but in this case IMPLICIT casting is used.
    select coalesce(CAST('x'AS VARBINARY), CAST('x' AS NVARCHAR(4000)), 'x')

Issues Resolved

BABEL-726 Engine PR : https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish/pull/380 Signed-off-by: Sai Rohan Basa bsrohan@amazon.com

Test Scenarios Covered

Check List

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.

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 9300401324

Details


Totals Coverage Status
Change from base Build 9287854680: 0.0%
Covered Lines: 41715
Relevant Lines: 56992

💛 - Coveralls