Skip to content

Commit d1e7cfd

Browse files
cursoragentlovasoa
andcommitted
Refactor: Fix set_variable serialization and update tests
Co-authored-by: contact <[email protected]>
1 parent 0e89124 commit d1e7cfd

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/webserver/database/sqlpage_functions/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ async fn set_variable<'a>(
634634
}
635635

636636
let json_val = serde_json::Value::Object(params_map);
637-
let encoded: URLParameters = serde_json::from_value(json_val)?;
637+
let encoded: URLParameters = serde_json::from_str(&json_val.to_string())?;
638638

639639
let mut url = context.path.clone();
640640
let encoded_str = encoded.get();
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
set url = sqlpage.set_variable('y', '2');
22
set path = sqlpage.path();
3+
set x = json_extract(sqlpage.variables('get'), '$.x');
4+
35
select 'text' as component,
46
case
5-
when $url = $path || '?x=1&y=2' OR $url = $path || '?y=2&x=1' THEN 'It works !'
7+
when $x is not null AND ($url = $path || '?x=' || $x || '&y=2' OR $url = $path || '?y=2&x=' || $x) THEN 'It works !'
8+
when $x is null AND $url = $path || '?y=2' THEN 'It works !'
69
else 'error: ' || $url
710
end as contents;

0 commit comments

Comments
 (0)