chore(*.psql): update functions; add update_artist_key.psql for merging artists flow
This commit is contained in:
parent
15982f220a
commit
678384d8d9
8 changed files with 48 additions and 19 deletions
|
@ -1,14 +1,21 @@
|
|||
CREATE OR REPLACE FUNCTION normalize_country_field(countryField TEXT)
|
||||
RETURNS TEXT AS $$
|
||||
DECLARE
|
||||
delimiters TEXT[] := ARRAY[',', '/', '&', 'and'];
|
||||
countries TEXT[];
|
||||
temp TEXT[];
|
||||
result TEXT := '';
|
||||
i INTEGER;
|
||||
BEGIN
|
||||
countries := string_to_array(countryField, ',');
|
||||
|
||||
FOR i IN 1..array_length(delimiters, 1) LOOP
|
||||
countries := array_cat(countries, string_to_array(result, delimiters[i]));
|
||||
temp := ARRAY[]::TEXT[];
|
||||
FOREACH result IN ARRAY countries LOOP
|
||||
temp := array_cat(temp, string_to_array(result, delimiters[i]));
|
||||
END LOOP;
|
||||
countries := temp;
|
||||
END LOOP;
|
||||
|
||||
result := array_to_string(countries, ' ');
|
||||
RETURN trim(result);
|
||||
END
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue