Can someone help me understand what's going on, here?
SELECT
jsonb_array_length(to_jsonb("gi"."colors_distilled")) "gi_colors_distilled_jsonb_len"
FROM
"general_inventories" "gi"
WHERE
"gi_colors_distilled_jsonb_len" > 1;
Fails with:
-- ERROR: column "gi_colors_distilled_jsonb_len" does not exist
-- LINE 6: "gi_colors_distilled_jsonb_len" > 1;
This works (implementing the expression directly within the condition), however:
SELECT
jsonb_array_length(to_jsonb("gi"."colors_distilled")) "gi_colors_distilled_jsonb_len"
FROM
"general_inventories" "gi"
WHERE
jsonb_array_length(to_jsonb("gi"."colors_distilled")) > 1;
It feels like I must be missing something obvious, but there's so little there that I must be botching an assumption about how/when aliases are evaluated.