File tree 1 file changed +9
-10
lines changed
1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -2118,28 +2118,27 @@ BEGIN
2118
2118
END;
2119
2119
$$ LANGUAGE plpgsql;
2120
2120
2121
+
2121
2122
CREATE OR REPLACE FUNCTION get_name_by_language (name hstore, languagepref TEXT []) RETURNS TEXT
2122
2123
AS $$
2123
2124
DECLARE
2124
- search TEXT [];
2125
- found BOOLEAN ;
2125
+ result TEXT ;
2126
2126
BEGIN
2127
-
2128
2127
IF name is null THEN
2129
2128
RETURN null ;
2130
2129
END IF;
2131
2130
2132
- search := languagepref;
2133
-
2134
- FOR j IN 1 ..array_upper(search, 1 ) LOOP
2135
- IF name ? search[j] AND trim (name- > search[j]) != ' ' THEN
2136
- return trim (name- > search[j]);
2131
+ FOR j IN 1 ..array_upper(languagepref,1 ) LOOP
2132
+ IF name ? languagepref[j] THEN
2133
+ result := trim (name- > languagepref[j]);
2134
+ IF result != ' ' THEN
2135
+ return result;
2136
+ END IF;
2137
2137
END IF;
2138
2138
END LOOP;
2139
2139
2140
2140
-- anything will do as a fallback - just take the first name type thing there is
2141
- search := avals(name);
2142
- RETURN search[1 ];
2141
+ RETURN trim ((avals(name))[1 ]);
2143
2142
END;
2144
2143
$$
2145
2144
LANGUAGE plpgsql IMMUTABLE;
You can’t perform that action at this time.
0 commit comments