-- Testing cross-types compatibility SELECT (0::uint4)::numeric; numeric --------- 0 (1 row) SELECT ('0'::numeric)::uint4; uint4 ------- 0 (1 row) SELECT ('4294967296'::numeric)::uint4; ERROR: uint4 out of range SELECT (0::uint4)::json; json ------ 0 (1 row) SELECT json_build_object('some', 0::uint4); json_build_object ------------------- {"some" : 0} (1 row) SELECT ('0'::json)::uint4; uint4 ------- 0 (1 row) SELECT (0::uint4)::jsonb; jsonb ------- 0 (1 row) SELECT jsonb_build_object('some', 0::uint4); jsonb_build_object -------------------- {"some": 0} (1 row) SELECT ('0'::jsonb)::uint4; uint4 ------- 0 (1 row) SELECT ('"abc"'::jsonb)::uint4; ERROR: cannot cast jsonb string to type uint4