Skip to content

Conversation

mariusandra
Copy link
Collaborator

@mariusandra mariusandra commented Jun 27, 2023

Problem

Typing ifNull(bla, 0) everywhere is cumbersome. I'm used to so much better from TypeScript.

Changes

Adds ??, so instead of

select length(JSONExtractArrayRaw(ifNull(properties.$active_feature_flags, '[]'))) from events limit 1

you can do

select length(JSONExtractArrayRaw(properties.$active_feature_flags ?? '[]')) from events limit 1

How did you test this code?

I took care to have the operator precedence match what JS does. So 1 + null ?? 2 + 3 translates to (1 + null) ?? (2 + 3), and not 1 + (null ?? 2) + 3.

Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice

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.

2 participants