Nikita Glukhov <n.glu...@postgrespro.ru> writes: > On 01.03.2018 11:19, Darafei "Komяpa" Praliaskouski wrote: >> I would expect some casts to be implicit, so that chaining with other >> functions is possible:
> I think that only cast to a numeric type can be made implicit, because > it does not lose precision. I hadn't been following this thread particularly, but I happened to notice this bit, and I thought I'd better pop up to say No Way. There will be *no* implicit casts from json to any numeric type. We have learned the hard way that implicit cross-category casts are dangerous. See the advice in the CREATE CAST man page: It is wise to be conservative about marking casts as implicit. An overabundance of implicit casting paths can cause PostgreSQL to choose surprising interpretations of commands, or to be unable to resolve commands at all because there are multiple possible interpretations. A good rule of thumb is to make a cast implicitly invokable only for information-preserving transformations between types in the same general type category. For example, the cast from int2 to int4 can reasonably be implicit, but the cast from float8 to int4 should probably be assignment-only. Cross-type-category casts, such as text to int4, are best made explicit-only. regards, tom lane