def _get_portable_table_foreign_keys_list(self, table_foreign_keys):
        foreign_keys = OrderedDict()

        for value in table_foreign_keys:
            value = dict((k.lower(), v) for k, v in value.items())
            name = value.get('constraint_name', '')

            if name not in foreign_keys:
                if 'delete_rule' not in value or value['delete_rule'] == 'RESTRICT':
                    value['delete_rule'] = ''

                if 'update_rule' not in value or value['update_rule'] == 'RESTRICT':
                    value['update_rule'] = ''

                foreign_keys[name] = {
                    'name': name,
                    'local': [],
                    'foreign': [],
                    'foreign_table': value['referenced_table_name'],
                    'on_delete': value['delete_rule'],
                    'on_update': value['update_rule']
                }

            foreign_keys[name]['local'].append(value['column_name'])
            foreign_keys[name]['foreign'].append(value['referenced_column_name'])

        result = []
        for constraint in foreign_keys.values():
            result.append(ForeignKeyConstraint(
                constraint['local'], constraint['foreign_table'],
                constraint['foreign'], constraint['name'],
                {
                    'on_delete': constraint['on_delete'],
                    'on_update': constraint['on_update']
                }
            ))

        return result
dataset/ETHPy150Open sdispater/orator/orator/dbal/mysql_schema_manager.py/MySQLSchemaManager._get_portable_table_foreign_keys_list/original