-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix typo in README #153
Fix typo in README #153
Conversation
README.md
Outdated
@@ -25,12 +25,12 @@ SELECT urlencode('my special string''s & things?'); | |||
URL encode a JSON associative array. | |||
|
|||
```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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you have an older version installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
::text
type 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!