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