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