From e87944e2ce808c41865a09c75c225c55b49c2f4b Mon Sep 17 00:00:00 2001 From: Ophir Lojkine Date: Sat, 28 Nov 2026 23:46:30 +0000 Subject: [PATCH] Correct the cookie round trip and streaming response examples --- .../official-site/sqlpage/migrations/01_documentation.sql | 2 +- examples/official-site/sqlpage/migrations/05_cookie.sql | 8 ++++---- examples/official-site/sqlpage/migrations/11_json.sql | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/official-site/sqlpage/migrations/01_documentation.sql b/examples/official-site/sqlpage/migrations/01_documentation.sql index 39b6d64ea..34d783997 100644 --- a/examples/official-site/sqlpage/migrations/01_documentation.sql +++ b/examples/official-site/sqlpage/migrations/01_documentation.sql @@ -1355,7 +1355,7 @@ select ''csv'' as component, ''example.csv'' as filename; SELECT * FROM my_large_table; ``` -#### `index.sql` +Link to `csv_download.sql` from a separate page with the button below. Opening the link starts the download without embedding the CSV data in the page that contains the button. ', json('[{"component":"button"}, {"title": "Download my data", "link": "/examples/csv_download.sql"}]')), ('csv', ' diff --git a/examples/official-site/sqlpage/migrations/05_cookie.sql b/examples/official-site/sqlpage/migrations/05_cookie.sql index 3b3816546..8e2f2db4f 100644 --- a/examples/official-site/sqlpage/migrations/05_cookie.sql +++ b/examples/official-site/sqlpage/migrations/05_cookie.sql @@ -106,20 +106,20 @@ VALUES ( INSERT INTO example (component, description) VALUES ( 'cookie', - 'Create a cookie named `username` with the value `John Doe`... + 'Set the cookie before producing any page content: ```sql SELECT ''cookie'' as component, ''username'' as name, - ''John Doe'' as value + ''John Doe'' as value, FALSE AS secure; -- You can remove this if the site is served over HTTPS. ``` -and then display the value of the cookie using the [`sqlpage.cookie`](functions.sql?function=cookie) function: +On a later request, read the value the browser sent with [`sqlpage.cookie`](functions.sql?function=cookie). Setting a response cookie does not change the current request. ```sql SELECT ''text'' as component, - ''Your name is '' || COALESCE(sqlpage.cookie(''username''), ''not known to us''); + ''Your name is '' || COALESCE(sqlpage.cookie(''username''), ''not known to us'') as contents; ``` ' ); diff --git a/examples/official-site/sqlpage/migrations/11_json.sql b/examples/official-site/sqlpage/migrations/11_json.sql index 8384ab58c..5c6010819 100644 --- a/examples/official-site/sqlpage/migrations/11_json.sql +++ b/examples/official-site/sqlpage/migrations/11_json.sql @@ -100,12 +100,12 @@ curl -H "Accept: application/json" http://localhost:8080/users.sql ( 'json', ' -## Send a single JSON object: `''jsonlines'' as type` +## Send one JSON object per row: `''jsonlines'' as type` In `jsonlines` mode, each query result is rendered as a JSON object in a separate line, without a top-level array. -If there is a single query result, the response will be a valid JSON object. +If there are no rows, the response body is empty. If there is a single row, the response is a JSON object. If there are multiple query results, you will need to parse each line of the response as a separate JSON object. If a query returns an error, the response will be a JSON object with an `error` property.