Skip to content

Commit 325b72f

Browse files
committed
fix handling of one-element arrays in doc code generator
1 parent 843d970 commit 325b72f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

examples/official-site/component.sql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ select
7575
group_concat(
7676
'select ' || char(10) ||
7777
(
78-
with t as (select * from json_tree(top.value)),
78+
with t as (
79+
select *,
80+
case type
81+
when 'array' then json_array_length(json_array(value))>1
82+
else false
83+
end as is_arr
84+
from json_tree(top.value)
85+
),
7986
key_val as (select
8087
CASE t.type
8188
WHEN 'integer' THEN t.atom
@@ -92,8 +99,8 @@ select
9299
ELSE parent.key
93100
END as key
94101
from t inner join t parent on parent.id = t.parent
95-
where ((parent.fullkey = '$' and t.type != 'array')
96-
or (parent.type = 'array' and parent.path = '$'))
102+
where ((parent.fullkey = '$' and not t.is_arr)
103+
or (parent.path = '$' and parent.is_arr))
97104
),
98105
key_val_padding as (select
99106
CASE

0 commit comments

Comments
 (0)