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