From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: JSON manipulation functions |
Date: | 2010-05-27 19:35:07 |
Message-ID: | 6547.1274988907@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com> writes:
> I tried making a function named json_type that has the same name as
> the type json_type. However, this doesn't work as expected:
> SELECT json_type('[1,2,3]');
> Instead of calling json_type with '[1,2,3]' casted to JSON, it's
> trying to cast '[1,2,3]' to json_type. Is there a way to override
> this behavior, or would I be better off renaming the function?
Well, that might not be the behavior you expected, but that doesn't
make it wrong. The above is, by convention, equivalent to
'[1,2,3]'::json_type, so it's acting as per convention.
If the function is a cast function (which it is), it *should* be named
after the destination type. Doing anything else will violate numerous
longstanding expectations. You might want to read the comments about
function-calls-as-casts in func_get_detail().
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2010-05-27 19:37:42 | Re: JSON manipulation functions |
Previous Message | Peter Eisentraut | 2010-05-27 19:32:25 | [9.1] pg_stat_get_backend_server_addr |