Skip to content

Commit

Permalink
add coalesce around boards description (mattermost-community#3289)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbishel authored Jun 29, 2022
1 parent f227a9e commit 429a4e4
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards (
SELECT B.id, B.insert_at, C.TeamId, B.channel_id, B.created_by, B.modified_by, C.type,
COALESCE(B.title, ''),
(B.fields->>'description')::text,
COALESCE((B.fields->>'description')::text, ''),
B.fields->>'icon',
COALESCE((fields->'showDescription')::text::boolean, false),
COALESCE((fields->'isTemplate')::text::boolean, false),
Expand All @@ -147,7 +147,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards_history (
SELECT B.id, B.insert_at, C.TeamId, B.channel_id, B.created_by, B.modified_by, C.type,
COALESCE(B.title, ''),
(B.fields->>'description')::text,
COALESCE((B.fields->>'description')::text, ''),
B.fields->>'icon',
COALESCE((fields->'showDescription')::text::boolean, false),
COALESCE((fields->'isTemplate')::text::boolean, false),
Expand All @@ -163,7 +163,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards (
SELECT B.id, B.insert_at, C.TeamId, B.channel_id, B.created_by, B.modified_by, C.Type,
COALESCE(B.title, ''),
JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.description')),
COALESCE(JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.description')), ''),
JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.icon')),
COALESCE(B.fields->'$.showDescription', 'false') = 'true',
COALESCE(JSON_EXTRACT(B.fields, '$.isTemplate'), 'false') = 'true',
Expand All @@ -177,7 +177,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards_history (
SELECT B.id, B.insert_at, C.TeamId, B.channel_id, B.created_by, B.modified_by, C.Type,
COALESCE(B.title, ''),
JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.description')),
COALESCE(JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.description')), ''),
JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.icon')),
COALESCE(B.fields->'$.showDescription', 'false') = 'true',
COALESCE(JSON_EXTRACT(B.fields, '$.isTemplate'), 'false') = 'true',
Expand All @@ -194,7 +194,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards (
SELECT id, insert_at, '0', channel_id, created_by, modified_by, 'O',
COALESCE(B.title, ''),
(fields->>'description')::text,
COALESCE((fields->>'description')::text, ''),
B.fields->>'icon',
COALESCE((fields->'showDescription')::text::boolean, false),
COALESCE((fields->'isTemplate')::text::boolean, false),
Expand All @@ -207,7 +207,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards_history (
SELECT id, insert_at, '0', channel_id, created_by, modified_by, 'O',
COALESCE(B.title, ''),
(fields->>'description')::text,
COALESCE((fields->>'description')::text, ''),
B.fields->>'icon',
COALESCE((fields->'showDescription')::text::boolean, false),
COALESCE((fields->'isTemplate')::text::boolean, false),
Expand All @@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards (
SELECT id, insert_at, '0', channel_id, created_by, modified_by, 'O',
COALESCE(B.title, ''),
JSON_UNQUOTE(JSON_EXTRACT(fields,'$.description')),
COALESCE(JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.description')), ''),
JSON_UNQUOTE(JSON_EXTRACT(fields,'$.icon')),
COALESCE(B.fields->'$.showDescription', 'false') = 'true',
COALESCE(JSON_EXTRACT(B.fields, '$.isTemplate'), 'false') = 'true',
Expand All @@ -235,7 +235,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards_history (
SELECT id, insert_at, '0', channel_id, created_by, modified_by, 'O',
COALESCE(B.title, ''),
JSON_UNQUOTE(JSON_EXTRACT(fields,'$.description')),
COALESCE(JSON_UNQUOTE(JSON_EXTRACT(B.fields,'$.description')), ''),
JSON_UNQUOTE(JSON_EXTRACT(fields,'$.icon')),
COALESCE(B.fields->'$.showDescription', 'false') = 'true',
COALESCE(JSON_EXTRACT(B.fields, '$.isTemplate'), 'false') = 'true',
Expand All @@ -250,7 +250,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards
SELECT id, insert_at, '0', channel_id, created_by, modified_by, 'O',
COALESCE(title, ''),
json_extract(fields, '$.description'),
COALESCE(json_extract(fields, '$.description'), ''),
json_extract(fields, '$.icon'), json_extract(fields, '$.showDescription'), json_extract(fields, '$.isTemplate'),
COALESCE(json_extract(fields, '$.templateVer'), 0),
'{}', json_extract(fields, '$.cardProperties'), create_at,
Expand All @@ -261,7 +261,7 @@ CREATE TABLE IF NOT EXISTS {{.prefix}}boards_history (
INSERT INTO {{.prefix}}boards_history
SELECT id, insert_at, '0', channel_id, created_by, modified_by, 'O',
COALESCE(title, ''),
json_extract(fields, '$.description'),
COALESCE(json_extract(fields, '$.description'), ''),
json_extract(fields, '$.icon'), json_extract(fields, '$.showDescription'), json_extract(fields, '$.isTemplate'),
COALESCE(json_extract(fields, '$.templateVer'), 0),
'{}', json_extract(fields, '$.cardProperties'), create_at,
Expand Down

0 comments on commit 429a4e4

Please sign in to comment.