Skip to content

Commit 2c11304

Browse files
authored
[6.0] Add tag lookup table information to make it possble to show the tag name instead of the tag id (#46174)
* update sql * [CMS PR 46174] Update the update SQL scripts and for new installations supports.sql (#21) * Names quotes for column names * Remove some tabs * Use separate lines for closing brackets * Fix SQL error "operator does not exist" * Append only once to array * Update supports.sql for new installations
1 parent d554f28 commit 2c11304

File tree

4 files changed

+81
-16
lines changed

4 files changed

+81
-16
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- Update content types for lookup tags
2+
3+
UPDATE `#__content_types`
4+
SET `content_history_options` = JSON_ARRAY_APPEND(
5+
`content_history_options`,
6+
'$.displayLookup',
7+
JSON_OBJECT(
8+
'sourceColumn', 'tags',
9+
'targetTable', '#__tags',
10+
'targetColumn', 'id',
11+
'displayColumn', 'title'
12+
)
13+
)
14+
WHERE `type_alias` IN (
15+
'com_content.article',
16+
'com_contact.contact',
17+
'com_newsfeeds.newsfeed',
18+
'com_content.category',
19+
'com_contact.category',
20+
'com_newsfeeds.category',
21+
'com_banners.category',
22+
'com_users.category'
23+
)
24+
AND NOT JSON_CONTAINS(
25+
JSON_EXTRACT(`content_history_options`, '$.displayLookup'),
26+
JSON_OBJECT(
27+
'sourceColumn', 'tags',
28+
'targetTable', '#__tags',
29+
'targetColumn', 'id',
30+
'displayColumn', 'title'
31+
)
32+
);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- Update content types for lookup tags
2+
3+
UPDATE "#__content_types"
4+
SET "content_history_options" = jsonb_set(
5+
"content_history_options"::jsonb,
6+
'{displayLookup}',
7+
"content_history_options"::jsonb->'displayLookup' ||
8+
jsonb_build_object(
9+
'sourceColumn', 'tags',
10+
'targetTable', '#__tags',
11+
'targetColumn', 'id',
12+
'displayColumn', 'title'
13+
)
14+
)
15+
WHERE "type_alias" IN (
16+
'com_content.article',
17+
'com_contact.contact',
18+
'com_newsfeeds.newsfeed',
19+
'com_content.category',
20+
'com_contact.category',
21+
'com_newsfeeds.category',
22+
'com_banners.category',
23+
'com_users.category'
24+
)
25+
AND NOT EXISTS (
26+
SELECT * FROM jsonb_array_elements("content_history_options"::jsonb->'displayLookup')
27+
WHERE value = jsonb_build_object(
28+
'sourceColumn', 'tags',
29+
'targetTable', '#__tags',
30+
'targetColumn', 'id',
31+
'displayColumn', 'title'
32+
)
33+
);

0 commit comments

Comments
 (0)