Skip to content

Commit

Permalink
fix(db): raw string triggers;
Browse files Browse the repository at this point in the history
- Changed the raw string triggers to unicode.
  • Loading branch information
JVickery-TBS committed Sep 20, 2024
1 parent 96bd1b9 commit d7515c0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ckanext/canada/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ def update_triggers():
{u'argname': u'choices', u'argtype': u'_text'},
{u'argname': u'field_name', u'argtype': u'text'}],
rettype=u'_text',
definition=r'''
definition='''
BEGIN
IF value IS NOT NULL AND value <> '' AND NOT (value = ANY (choices)) THEN
-- \t is used when converting errors to string
-- \\t is used when converting errors to string
RETURN ARRAY[[field_name, 'Invalid choice: {}\uF8FF"'
|| replace(value, E'\t', ' ') || '"']];
|| replace(value, E'\\t', ' ') || '"']];
END IF;
RETURN NULL;
END;
Expand Down Expand Up @@ -280,16 +280,16 @@ def update_triggers():
{u'argname': u'clean', u'argtype': u'_text', u'argmode': u'out'},
{u'argname': u'error', u'argtype': u'_text', u'argmode': u'out'}],
rettype=u'record',
definition=r'''
definition='''
DECLARE
bad_choices text := array_to_string(ARRAY(
SELECT c FROM(SELECT unnest(value) as c) u
WHERE NOT c = ANY(choices)), ',');
BEGIN
IF bad_choices <> '' THEN
-- \t is used when converting errors to string
-- \\t is used when converting errors to string
error := ARRAY[[field_name, 'Invalid choice: {}\uF8FF"'
|| replace(bad_choices, E'\t', ' ') || '"']];
|| replace(bad_choices, E'\\t', ' ') || '"']];
END IF;
clean := ARRAY(
SELECT c FROM(SELECT unnest(choices) as c) u
Expand Down

0 comments on commit d7515c0

Please sign in to comment.