def _make_trigger_for_attributes(insert_or_update, table, column):
    'Return a SQL statement for creating a temporary trigger. The\n    trigger is used to validate the contents of TEXT_ATTRIBUTES\n    type columns.\n\n    The trigger will pass without error if the JSON is a wellformed\n    "object" containing "text" values.\n\n    The trigger will raise an error if the value is:\n\n      * not wellformed JSON\n      * not an "object" type\n      * an "object" type that contains one or more "integer", "real",\n        "true", "false", "null", "object" or "array" types\n    '
    if (insert_or_update.upper() not in {'INSERT', 'UPDATE'}):
        msg = f"expected 'INSERT' or 'UPDATE', got {insert_or_update!r}"
        raise ValueError(msg)
    if SQLITE_JSON1_ENABLED:
        when_clause = f'''
            NEW.{column} IS NOT NULL
            AND (json_valid(NEW.{column}) = 0
                 OR json_type(NEW.{column}) != 'object'
                 OR (SELECT COUNT(*)
                     FROM json_each(NEW.{column})
                     WHERE json_each.type != 'text') != 0)
        '''.rstrip()
    else:
        when_clause = f'''
            NEW.{column} IS NOT NULL
            AND is_wellformed_attributes(NEW.{column}) = 0
        '''.rstrip()
    return f'''
        CREATE TEMPORARY TRIGGER IF NOT EXISTS trigger_check_{insert_or_update.lower()}_{table}_{column}
        BEFORE {insert_or_update.upper()} ON main.{table} FOR EACH ROW
        WHEN{when_clause}
        BEGIN
            SELECT RAISE(ABORT, '{table}.{column} must be a JSON object with text values');
        END;
    '''
Return a SQL statement for creating a temporary trigger. The
trigger is used to validate the contents of TEXT_ATTRIBUTES
type columns.

The trigger will pass without error if the JSON is a wellformed
"object" containing "text" values.

The trigger will raise an error if the value is:

  * not wellformed JSON
  * not an "object" type
  * an "object" type that contains one or more "integer", "real",
    "true", "false", "null", "object" or "array" types
def _make_trigger_for_attributes(insert_or_update, table, column):
    'Return a SQL statement for creating a temporary trigger. The\n    trigger is used to validate the contents of TEXT_ATTRIBUTES\n    type columns.\n\n    The trigger will pass without error if the JSON is a wellformed\n    "object" containing "text" values.\n\n    The trigger will raise an error if the value is:\n\n      * not wellformed JSON\n      * not an "object" type\n      * an "object" type that contains one or more "integer", "real",\n        "true", "false", "null", "object" or "array" types\n    '
    if (insert_or_update.upper() not in {'INSERT', 'UPDATE'}):
        msg = f"expected 'INSERT' or 'UPDATE', got {insert_or_update!r}"
        raise ValueError(msg)
    if SQLITE_JSON1_ENABLED:
        when_clause = f'
            NEW.{column} IS NOT NULL
            AND (json_valid(NEW.{column}) = 0
                 OR json_type(NEW.{column}) != 'object'
                 OR (SELECT COUNT(*)
                     FROM json_each(NEW.{column})
                     WHERE json_each.type != 'text') != 0)
        '.rstrip()
    else:
        when_clause = f'
            NEW.{column} IS NOT NULL
            AND is_wellformed_attributes(NEW.{column}) = 0
        '.rstrip()
    return f'
        CREATE TEMPORARY TRIGGER IF NOT EXISTS trigger_check_{insert_or_update.lower()}_{table}_{column}
        BEFORE {insert_or_update.upper()} ON main.{table} FOR EACH ROW
        WHEN{when_clause}
        BEGIN
            SELECT RAISE(ABORT, '{table}.{column} must be a JSON object with text values');
        END;
    '