Re: jsonpath versus NaN
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Korotkov <a.korotkov@postgrespro.ru>
Cc: Oleg Bartunov <obartunov@postgrespro.ru>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-06-18T16:45:46Z
Lists: pgsql-hackers
Alexander Korotkov <a.korotkov@postgrespro.ru> writes: > Thank you for your answer. I'm trying to understand your point. > Standard claims that .double() method should behave the same way as > CAST to double. However, standard references the standard behavior of > CAST here, not behavior of your implementation of CAST. So, if we > extend the functionality of standard CAST in our implementation, that > doesn't automatically mean we should extend the .double() jsonpath > method in the same way. Is it correct? Right. We could, if we chose, extend jsonpath to allow Inf/NaN, but I don't believe there's an argument that the spec requires us to. Also the larger point is that it doesn't make sense to extend jsonpath that way when we haven't extended json(b) that way. This code wart wouldn't exist were it not for that inconsistency. Also, I find it hard to see why anyone would have a use for NaN in a jsonpath test when they can't write NaN in the input json data, nor have it be correctly reflected into output json data either. Maybe there's a case for extending json(b) that way; it wouldn't be so different from the work I'm doing nearby to extend type numeric for infinities. But we'd have to have a conversation about whether interoperability with other JSON implementations is worth sacrificing to improve consistency with our float and numeric datatypes. In the meantime, though, we aren't allowing Inf/NaN in json(b) so I don't think jsonpath should accept them either. regards, tom lane
Commits
-
Forbid numeric NaN in jsonpath
- f4ae676e3178 12.4 landed
- 89a0b1a7ca0a 13.0 landed
- df646509f371 14.0 landed
-
Improve error reporting for jsonpath .double() method
- 3ec5f6b53dfb 12.4 landed
- b9a04a9bc665 13.0 landed
- 065718116746 14.0 landed
-
Partial implementation of SQL/JSON path language
- 72b6460336e8 12.0 cited