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