Skip to content

Commit 49ab2be

Browse files
committed
add null handling for search input and clean up whitespace
fixes #884 (comment)
1 parent c323bde commit 49ab2be

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/official-site/search.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
set search = nullif(trim($search), '');
2+
13
-- Check for exact matches and redirect if found
24
set redirect = CASE
35
WHEN EXISTS (SELECT 1 FROM component WHERE name = $search) THEN sqlpage.link('/component.sql', json_object('component', $search))
46
WHEN EXISTS (SELECT 1 FROM sqlpage_functions WHERE name = $search) THEN sqlpage.link('/functions.sql', json_object('function', $search))
57
END
68
SELECT 'redirect' as component, $redirect as link WHERE $redirect IS NOT NULL;
79

8-
910
select 'dynamic' as component, json_patch(json_extract(properties, '$[0]'), json_object(
1011
'title', coalesce($search || ' | ', '') || 'SQLPage documentation search'
1112
)) as properties

0 commit comments

Comments
 (0)