fix: recursively process all expressions in COALESCE arguments#53
Merged
exAspArk merged 1 commit intoBemiHQ:mainfrom Nov 4, 2025
Merged
fix: recursively process all expressions in COALESCE arguments#53exAspArk merged 1 commit intoBemiHQ:mainfrom
exAspArk merged 1 commit intoBemiHQ:mainfrom
Conversation
This commit addresses two issues with PostgreSQL compatibility: 1. COALESCE expression handling: - Recursively process all expressions in COALESCE arguments - Handles nested function calls within COALESCE (e.g., jsonb_array_length) - Previously only processed SubLink nodes, now handles all expression types 2. jsonb_array_length return type: - Cast result to INTEGER to match PostgreSQL's int4 return type (OID 23) - PostgreSQL's jsonb_array_length() returns INTEGER, not BIGINT or UBIGINT - Updated test expectations from XID8OID (5069) to Int4OID (23) Tests added: - COALESCE with JSONB types - jsonb_array_length with COALESCE expressions
Member
|
@JC1738 thank you! This looks great! 🙌 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The COALESCE expression handler was only processing SubLink (nested SELECT)
arguments, but not other expression types like TypeCast nodes. This caused
queries with '[]'::jsonb inside COALESCE to fail with "Type jsonb does not
exist" errors, since the ::jsonb->::json remapping never occurred.
Changed COALESCE handler to recursively process all argument types using
remappedExpressions(), matching the pattern used for function calls and
boolean expressions. This ensures type casts and other expressions are
properly remapped regardless of nesting context.
Added test coverage for COALESCE with jsonb type casts.