Skip to content

Commit d79e8ff

Browse files
committed
Fix test to work across all databases without json_extract
PostgreSQL doesn't have json_extract, so compare the full JSON string instead.
1 parent e742b8f commit d79e8ff

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tests/sql_test_files/it_works_immutable_variables_nomssql_nopostgres_nomysql.sql renamed to tests/sql_test_files/it_works_immutable_variables.sql

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
-- This test uses json_extract() which is SQLite-specific
21
SET x = 'set_value';
32
SET set_only = 'only_in_set';
43

@@ -16,19 +15,17 @@ SELECT CASE
1615
END AS contents;
1716

1817
SELECT CASE
19-
WHEN json_extract(sqlpage.variables('get'), '$.x') = '1' THEN 'It works !'
20-
ELSE 'FAIL: variables(''get'') should return only URL parameters'
18+
WHEN sqlpage.variables('get') = '{"x":"1"}' THEN 'It works !'
19+
ELSE 'FAIL: variables(''get'') should return only URL parameters, got: ' || sqlpage.variables('get')
2120
END AS contents;
2221

2322
SELECT CASE
24-
WHEN json_extract(sqlpage.variables('set'), '$.x') = 'set_value' AND
25-
json_extract(sqlpage.variables('set'), '$.set_only') = 'only_in_set' THEN 'It works !'
26-
ELSE 'FAIL: variables(''set'') should return only SET variables'
23+
WHEN sqlpage.variables('set') = '{"x":"set_value","set_only":"only_in_set"}' THEN 'It works !'
24+
ELSE 'FAIL: variables(''set'') should return only SET variables, got: ' || sqlpage.variables('set')
2725
END AS contents;
2826

2927
SELECT CASE
30-
WHEN json_extract(sqlpage.variables(), '$.x') = 'set_value' AND
31-
json_extract(sqlpage.variables(), '$.set_only') = 'only_in_set' THEN 'It works !'
32-
ELSE 'FAIL: variables() should merge all with SET taking precedence'
28+
WHEN sqlpage.variables() = '{"x":"set_value","set_only":"only_in_set"}' THEN 'It works !'
29+
ELSE 'FAIL: variables() should merge all with SET taking precedence, got: ' || sqlpage.variables()
3330
END AS contents;
3431

0 commit comments

Comments
 (0)