File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change 6666 const whereCondition = WHERE . length ? `WHERE ${ WHERE . join ( ' AND ' ) } ` : ''
6767
6868 const stmt = db . prepare ( `
69- WITH snippet_data AS (
69+ WITH snippet_contents_data AS (
70+ SELECT
71+ snippetId,
72+ json_group_array(
73+ json_object(
74+ 'id', id,
75+ 'label', label,
76+ 'value', value,
77+ 'language', language
78+ )
79+ ) as contents
80+ FROM snippet_contents
81+ GROUP BY snippetId
82+ ),
83+ snippet_data AS (
7084 SELECT
7185 s.id,
7286 s.name,
88102 'name', t.name
89103 )
90104 ) FILTER (WHERE t.id IS NOT NULL) as tags,
91- json_group_array(
92- json_object(
93- 'id', sc.id,
94- 'label', sc.label,
95- 'value', sc.value,
96- 'language', sc.language
97- )
98- ) FILTER (WHERE sc.id IS NOT NULL) as contents
105+ COALESCE(scd.contents, '[]') as contents
99106 FROM snippets s
100107 LEFT JOIN folders f ON s.folderId = f.id
101108 LEFT JOIN snippet_tags st ON s.id = st.snippetId
102109 LEFT JOIN tags t ON st.tagId = t.id
103- LEFT JOIN snippet_contents sc ON s.id = sc .snippetId
110+ LEFT JOIN snippet_contents_data scd ON s.id = scd .snippetId
104111 ${ whereCondition }
105112 GROUP BY s.id
106113 )
You can’t perform that action at this time.
0 commit comments