• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

babelfish-for-postgresql / babelfish_extensions / 11119835728 / 1
76%
BABEL_5_X_DEV: 77%

Build:
Build:
LAST BUILD BRANCH: BABEL-6084-test-fix
DEFAULT BRANCH: BABEL_5_X_DEV
Ran 01 Oct 2024 07:02AM UTC
Files 115
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

01 Oct 2024 06:26AM UTC coverage: 74.474% (+0.004%) from 74.47%
11119835728.1

push

github

web-flow
Fix CASE statement when branch expression is of String Datatype. (#2931)

Issue:

Return type of overall CASE expression when branch expression is of string datatype gives a different return type as
compared to TSQL expression.

eg. Return type of overall CASE expression is evaluated to become VARCHAR, if all branches are of NVARCHAR type
because Postgres tries to coerce result of every branch expression to base type (VARCHAR), whereas in TSQL, overall
return type is NVARCHAR in this example.

CREATE TABLE ALLTEXTS(
  CODE nvarchar(30) NOT NULL,
  LANG nvarchar(2) NOT NULL,
  TEXT nvarchar(2000) NULL
)

INSERT INTO ALLTEXTS (CODE, LANG, TEXT) VALUES ('53075', 'EN', N'Registration Card - Standard');

INSERT INTO ALLTEXTS (CODE, LANG, TEXT) VALUES ('53075', 'AR', N'بطاقة التسجيل - قياسية');

INSERT INTO ALLTEXTS (CODE, LANG, TEXT) VALUES ('53075', 'JP', N'登録カード–標準');

SELECT CASE WHEN 1 = 1 THEN TEXT END AS WrongValue2 FROM ALLTEXTS

Return type: varchar
expected type: nvarchar

Changes made to fix the issues:

tsql_select_common_type_hook() is set to return common_type for all branches when branch expression is of string
datatype, that calculate according to the TSQL precedence, whereas till now it was set according to the PG precedence
order (which was different from TSQL). This hook solved our problem as it returns result according to the TSQL
precedence order. 

We have also fixed the typmod of resultant expression by calculating the common typmod and setting all branches of
CASE statement to the calculated typmod.

Task: BABEL-5103, BABEL-4332
Signed-off-by: Yashneet Vinayak <yashneet@amazon.com>

45121 of 60586 relevant lines covered (74.47%)

162232.64 hits per line

Source Files on job 11119835728.1
  • Tree
  • List 115
  • Changed 77
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 11119835728
  • 43f1a579 on github
  • Prev Job for on BABEL_4_X_DEV (#11109596996.1)
  • Next Job for on BABEL_4_X_DEV (#11122537724.1)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc