On 04/08/2025 07:55, David G. Johnston wrote:
On Sunday, August 3, 2025, Corey Huinker <corey.huinker@gmail.com> wrote:
I was under the impression that for format to be allowed in the expression one of the two data types involved has to be text and the other must not be text.
I hadn't understood that, but also hadn't thought of a case where it might be wanted until just now. What if someone wanted a cast from JSONB to their custom type, and the format was a specific keypath to extract from the JSONB? It's true that could be accomplished by first extracting the keypath and then CASTing that expression, but the same is true for text->date, regexing a YYYY-MM-DD into the locale default.
Feels like the same basic answer. Create cast has a single (because it’s one-way) function accepting between 1 and 3 arguments. Change it to accept between 1 and 4 arguments and the 4th is where the format expression gets passed. If a format expression is present and the function doesn’t have a 4th argument, error.
This is my position as well.
+1
--
Vik Fearing