Fix typo in README#153
Conversation
README.md
Outdated
|
|
||
| ```sql | ||
| SELECT urlencode(jsonb_build_object('name','Colin & James','rate','50%')); | ||
| SELECT urlencode(jsonb_build_object('name','Colin & James','rate','50%')::text); |
There was a problem hiding this comment.
Nope, this isn't right... when URL encoding an associative array one wants the keys and values encoded independently, just like the example output shows
There was a problem hiding this comment.
Ah, I see. Okay, let me revert that. Although, the command still doesn't work with no type cast and also when I try with ::jsonb. It returns ERROR: function urlencode(jsonb) does not exist. I took a look at the code, but C confuses me.
There was a problem hiding this comment.
Perhaps you have an older version installed.
There was a problem hiding this comment.
Hmm, interesting!
postgres=# select version();
version
-----------------------------------------------------------------------------------------------------------------------------
PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
(1 row)
postgres=# SELECT *
FROM pg_extension;
oid | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition
-------+---------+----------+--------------+----------------+------------+-----------+--------------
13743 | plpgsql | 10 | 11 | f | 1.0 | |
16384 | pg_trgm | 10 | 2200 | t | 1.6 | |
16465 | http | 10 | 2200 | t | 1.3 | |
16510 | plv8 | 10 | 11 | f | 3.0alpha | |
(4 rows)
postgres=# SELECT urlencode(jsonb_build_object('name','Colin & James','rate','50%'));
ERROR: function urlencode(jsonb) does not exist
LINE 1: SELECT urlencode(jsonb_build_object('name','Colin & James','...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Anything look strange? I am using the Supabase Postgres Docker image so maybe something is wrong there.
Anyway, thanks for taking a look!
There was a problem hiding this comment.
Ah, 1.4 adds the url encoding of jsonb. heh heh.
|
Works 100% for me: |
👋 Hello! This PR fixes a couple of small typos I found when trying out some of the examples. I am not sure that adding the
::texttype cast to the urlencode of the json_build_object is the best way, but it is the only way I found it would work.Thanks!