You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Returns a URL with the specified variable set to the given value, preserving other existing variables.
6
+
- This is a shorthand for `sqlpage.link(sqlpage.path(), json_patch(sqlpage.variables('get'), json_object(name, value)))`.
4
7
-**Variable System Improvements**: URL and POST parameters are now immutable, preventing accidental modification. User-defined variables created with `SET` remain mutable.
5
8
-**BREAKING**: `$variable` no longer accesses POST parameters. Use `:variable` instead.
6
9
-**What changed**: Previously, `$x` would return a POST parameter value if no GET parameter named `x` existed.
'Returns a URL that is the same as the current page''s URL, but with a variable set to a new value.
14
+
15
+
This function is useful when you want to create a link that changes a parameter on the current page, while preserving other parameters.
16
+
17
+
It is equivalent to `sqlpage.link(sqlpage.path(), json_patch(sqlpage.variables(''get''), json_object(name, value)))`.
18
+
19
+
### Example
20
+
21
+
Let''s say you have a list of products, and you want to filter them by category. You can use `sqlpage.set_variable` to create links that change the category filter, without losing other potential filters (like a search query or a sort order).
22
+
23
+
```sql
24
+
select ''button'' as component, ''sm'' as size, ''center'' as justify;
25
+
select
26
+
category as title,
27
+
sqlpage.set_variable(''category'', category) as link,
28
+
case when $category = category then ''primary'' else ''secondary'' end as color
29
+
from categories;
30
+
```
31
+
32
+
### Parameters
33
+
- `name` (TEXT): The name of the variable to set.
34
+
- `value` (TEXT): The value to set the variable to. If `NULL` is passed, the variable is removed from the URL.
0 commit comments