| From: | Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> |
|---|---|
| To: | Erik Rijkers <er(at)xs4all(dot)nl> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: ERROR: operator does not exist: json = json |
| Date: | 2022-07-08 11:57:19 |
| Message-ID: | 87wncnizq8.fsf@wibble.ilmari.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Erik Rijkers <er(at)xs4all(dot)nl> writes:
> Hi,
>
> Comparison of 2 values of type jsonb is allowed.
>
> Comparison of 2 values of type json gives an error.
>
> That seems like an oversight -- or is it deliberate?
This is because json is just a textual representation, and different
JSON strings can be semantically equal because e.g. whitespace and
object key order is not significant.
> Example:
>
> select '42'::json = '{}'::json;
> --> ERROR: operator does not exist: json = json
>
> (of course, easily 'solved' by casting but that's not really the
> point)
To do a proper comparison you have to parse it into a semantic form,
which is what casting to jsonb does.
> Thanks,
>
> Erik Rijkers
- ilmari
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Steele | 2022-07-08 12:01:06 | Re: Add function to return backup_label and tablespace_map |
| Previous Message | Bharath Rupireddy | 2022-07-08 11:53:17 | Re: Add function to return backup_label and tablespace_map |