From 4987db92a31c790adac2fb1c636063750f41e29f Mon Sep 17 00:00:00 2001 From: Ophir Lojkine Date: Sat, 28 Nov 2026 23:46:30 +0000 Subject: [PATCH] Clarify request inputs, Basic Auth, paths, and URL fragments --- .../official-site/sqlpage/migrations/08_functions.sql | 7 +++---- .../sqlpage/migrations/20_variables_function.sql | 6 ++++-- examples/official-site/sqlpage/migrations/47_link.sql | 10 ++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/official-site/sqlpage/migrations/08_functions.sql b/examples/official-site/sqlpage/migrations/08_functions.sql index 30a8a7835..335729e56 100644 --- a/examples/official-site/sqlpage/migrations/08_functions.sql +++ b/examples/official-site/sqlpage/migrations/08_functions.sql @@ -76,8 +76,7 @@ VALUES ( 'header', '0.7.2', 'heading', - 'Reads a [header](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields) with the given name from the request. - Returns the value of the header as text, or NULL if the header is not present. + 'Reads one [HTTP request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers). Names are case-insensitive: `sqlpage.header(''User-Agent'')` and `sqlpage.header(''user-agent'')` read the same value. An absent header returns SQL `NULL`. ### Example @@ -135,7 +134,7 @@ SELECT ''authentication'' AS component, '0.7.2', 'key', 'Returns the password from the [Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) header of the request. - If the header is not present, this function raises an authorization error that will prompt the user to enter their credentials. +If the header is absent, SQLPage sends an HTTP Basic challenge. Browsers normally respond by prompting for credentials. ### Example @@ -262,7 +261,7 @@ Currently running from `/home/user/my_sqlpage_website` The current working directory is the directory from which the SQLPage server process was started. By default, this is also the directory from which `.sql` files are loaded and served. -However, this can be changed by setting the `web_root` [configuration option](https://github.com/sqlpage/SQLPage/blob/main/configuration.md). +Setting [`web_root`](https://github.com/sqlpage/SQLPage/blob/main/configuration.md) changes where SQLPage serves files. It does not change the process working directory. Use [`sqlpage.web_root()`](?function=web_root) to get the directory actually being served. ' ); INSERT INTO sqlpage_functions ( diff --git a/examples/official-site/sqlpage/migrations/20_variables_function.sql b/examples/official-site/sqlpage/migrations/20_variables_function.sql index 792285695..a0379d774 100644 --- a/examples/official-site/sqlpage/migrations/20_variables_function.sql +++ b/examples/official-site/sqlpage/migrations/20_variables_function.sql @@ -30,7 +30,9 @@ For more information about SQLPage variables, see the [*SQL in SQLPage* guide](/ - `sqlpage.variables(''post'')` - returns only POST form data - `sqlpage.variables(''set'')` - returns only user-defined variables created with `SET` -When a SET variable has the same name as a GET or POST variable, the SET variable takes precedence in the combined result. +For example, after `SET page = NULL` on a request to `?page=2`, +`sqlpage.variables(''get'')` still contains `"page":"2"`. +The combined `sqlpage.variables()` contains `"page":null`. ## Example: a form with a variable number of fields @@ -114,6 +116,6 @@ VALUES ( 'variables', 1, 'method', - 'Optional. Filter variables by source: ''get'' (URL parameters), ''post'' (form data), or ''set'' (user-defined variables). When not provided, all variables are returned with SET variables taking precedence over request parameters.', + 'Filter by source: `get` for URL parameters, `post` for form fields, or `set` for page variables. With no argument, the result combines all three.', 'TEXT' ); diff --git a/examples/official-site/sqlpage/migrations/47_link.sql b/examples/official-site/sqlpage/migrations/47_link.sql index 267a728d2..0d2949983 100644 --- a/examples/official-site/sqlpage/migrations/47_link.sql +++ b/examples/official-site/sqlpage/migrations/47_link.sql @@ -38,10 +38,12 @@ where name = $product_name; > but using `sqlpage.link` is better because it ensures that the URL is properly encoded. > `sqlpage.link` will work even if the product name contains special characters like `&`, while `CONCAT(...)` would break the URL. -### Parameters - - `file` (TEXT): The name of the SQLPage file to link to. - - `parameters` (JSON): The parameters to pass to the linked file. - - `fragment` (TEXT): An optional fragment (hash) to append to the URL. This is useful for linking to a specific section of a page. For instance if `product.sql` contains `select ''text'' as component, ''product_description'' as id;`, you can link to the product description section with `sqlpage.link(''product.sql'', json_object(''product_name'', name), ''product_description'')`. +To link directly to a section, pass its `id` as the third argument, without the `#`: + +```sql +select sqlpage.link(''product.sql'', json_object(''product_name'', name), ''product_description'') as link +from products; +``` ' );