Skip to content

Commit bac3fe9

Browse files
committed
Add database-specific examples for accessing original URL parameters
1 parent d1ff556 commit bac3fe9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
- **Example**: Change `SELECT $username` to `SELECT :username` when reading form submissions.
99
- **BREAKING**: `SET $name` no longer overwrites GET (URL) parameters when a URL parameter with the same name exists.
1010
- **What changed**: `SET $name = 'value'` would previously overwrite the URL parameter `$name`. Now it creates an independent SET variable that shadows the URL parameter.
11-
- **Fix**: This is generally the desired behavior. If you need to access the original URL parameter after setting a variable with the same name, use `sqlpage.variables('get')` to access it.
12-
- **Example**: If your URL is `page.sql?name=john`, and you do `SET $name = 'modified'`, then `$name` will be 'modified'. The original URL parameter is still accessible via `sqlpage.variables('get')` but not via `$name` anymore.
11+
- **Fix**: This is generally the desired behavior. If you need to access the original URL parameter after setting a variable with the same name, extract it from the JSON returned by `sqlpage.variables('get')`.
12+
- **Example**: If your URL is `page.sql?name=john`, and you do `SET $name = 'modified'`, then:
13+
- `$name` will be `'modified'` (the SET variable)
14+
- The original URL parameter is still preserved and accessible:
15+
- PostgreSQL: `sqlpage.variables('get')->>'name'` returns `'john'`
16+
- SQLite: `json_extract(sqlpage.variables('get'), '$.name')` returns `'john'`
17+
- MySQL: `JSON_UNQUOTE(JSON_EXTRACT(sqlpage.variables('get'), '$.name'))` returns `'john'`
1318
- **New behavior**: Variable lookup now follows this precedence:
1419
- `$variable` checks SET variables first, then URL parameters
1520
- `:variable` checks SET variables first, then POST parameters

0 commit comments

Comments
 (0)