6 Commits

Author SHA1 Message Date
lovasoa 16c089705c Fix: sqlpage.variables() no longer returns duplicate keys
The `sqlpage.variables()` function previously allowed duplicate keys
when GET, POST, and SET variables of the same name were present. This
commit ensures that the returned JSON object contains only unique keys,
with precedence given to SET variables, then POST, then GET.
2025-12-30 03:12:29 +01:00
Ophir LOJKINE b11e7bf0ff Make URL and POST parameters immutable (#1109)
* Make URL and POST parameters immutable, separate from SET variables

- URL and POST parameters are now immutable after request initialization
- SET command creates user-defined variables in separate namespace
- Variable lookup: SET variables shadow request parameters
- Added sqlpage.variables('set') to inspect user-defined variables
- Simplified API: most functions now use &RequestInfo instead of &mut
- All tests passing (151 total)

* Restore deprecation warning for SET on POST variable names

* Restore deprecation warnings for $var accessing POST variables

- Warn when both URL and POST have same variable name
- Warn when $var is used for POST-only variable (should use :var)

* Simplify run_sql: always use clone_without_variables

No need to branch on whether variables are provided since we clone in both cases anyway.

* Revert "Simplify run_sql: always use clone_without_variables"

This reverts commit 60f5a05446.

* Fix cross-database test compatibility for immutable variables

Renamed test to run only on SQLite since json_extract() is SQLite-specific.
Other databases (PostgreSQL, MySQL, MSSQL) have different JSON functions.

* Fix test to work across all databases without json_extract

PostgreSQL doesn't have json_extract, so compare the full JSON string instead.

* Document variable system improvements in CHANGELOG

* Make CHANGELOG more explicit about breaking changes with examples

* Fix CHANGELOG: SET overwrites GET parameters, not POST

* Add database-specific examples for accessing original URL parameters
2025-11-19 03:10:54 +01:00
lovasoa ffee882dfa fix documentation of sqlpage.variables 2024-05-11 14:14:13 +02:00
lovasoa e107919b3b update the documentation to match the new json_table support 2024-02-06 10:41:00 +01:00
ophir b1cf6c40f1 improve docs for mysql 2023-10-22 01:00:35 +02:00
ophir 17720bfcba new function: sqlpage.variables 2023-10-22 00:41:40 +02:00