We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
JIRA setup: change password field name to "API Token"
While a password can be used there, it's not recommended and eventually will be deprecated. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `redash/query_runner/jql.py`
Content:
```
1 import re
2 from collections import OrderedDict
3 
4 from redash.query_runner import *
5 from redash.utils import json_dumps, json_loads
6 
7 
8 # TODO: make this more general and move into __init__.py
9 class ResultSet(object):
10     def __init__(self):
11         self.columns = OrderedDict()
12         self.rows = []
13 
14     def add_row(self, row):
15         for key in row.keys():
16             self.add_column(key)
17 
18         self.rows.append(row)
19 
20     def add_column(self, column, column_type=TYPE_STRING):
21         if column not in self.columns:
22             self.columns[column] = {'name': column, 'type': column_type, 'friendly_name': column}
23 
24     def to_json(self):
25         return json_dumps({'rows': self.rows, 'columns': self.columns.values()})
26 
27     def merge(self, set):
28         self.rows = self.rows + set.rows
29 
30 
31 def parse_issue(issue, field_mapping):
32     result = OrderedDict()
33     result['key'] = issue['key']
34 
35     for k, v in issue['fields'].iteritems():#
36         output_name = field_mapping.get_output_field_name(k)
37         member_names = field_mapping.get_dict_members(k)
38 
39         if isinstance(v, dict):
40             if len(member_names) > 0:
41                 # if field mapping with dict member mappings defined get value of each member
42                 for member_name in member_names:
43                     if member_name in v:
44                         result[field_mapping.get_dict_output_field_name(k, member_name)] = v[member_name]
45 
46             else:
47                 # these special mapping rules are kept for backwards compatibility
48                 if 'key' in v:
49                     result['{}_key'.format(output_name)] = v['key']
50                 if 'name' in v:
51                     result['{}_name'.format(output_name)] = v['name']
52 
53                 if k in v:
54                     result[output_name] = v[k]
55 
56                 if 'watchCount' in v:
57                     result[output_name] = v['watchCount']
58 
59         elif isinstance(v, list):
60             if len(member_names) > 0:
61                 # if field mapping with dict member mappings defined get value of each member
62                 for member_name in member_names:
63                     listValues = []
64                     for listItem in v:
65                         if isinstance(listItem, dict):
66                             if member_name in listItem:
67                                 listValues.append(listItem[member_name])
68                     if len(listValues) > 0:
69                         result[field_mapping.get_dict_output_field_name(k, member_name)] = ','.join(listValues)
70 
71             else:
72                 # otherwise support list values only for non-dict items
73                 listValues = []
74                 for listItem in v:
75                     if not isinstance(listItem, dict):
76                         listValues.append(listItem)
77                 if len(listValues) > 0:
78                     result[output_name] = ','.join(listValues)
79 
80         else:
81             result[output_name] = v
82 
83     return result
84 
85 
86 def parse_issues(data, field_mapping):
87     results = ResultSet()
88 
89     for issue in data['issues']:
90         results.add_row(parse_issue(issue, field_mapping))
91 
92     return results
93 
94 
95 def parse_count(data):
96     results = ResultSet()
97     results.add_row({'count': data['total']})
98     return results
99 
100 
101 class FieldMapping:
102 
103     def __init__(cls, query_field_mapping):
104         cls.mapping = []
105         for k, v in query_field_mapping.iteritems():
106             field_name = k
107             member_name = None
108 
109             # check for member name contained in field name
110             member_parser = re.search('(\w+)\.(\w+)', k)
111             if (member_parser):
112                 field_name = member_parser.group(1)
113                 member_name = member_parser.group(2)
114 
115             cls.mapping.append({
116                 'field_name': field_name,
117                 'member_name': member_name,
118                 'output_field_name': v
119                 })
120 
121     def get_output_field_name(cls, field_name):
122         for item in cls.mapping:
123             if item['field_name'] == field_name and not item['member_name']:
124                 return item['output_field_name']
125         return field_name
126 
127     def get_dict_members(cls, field_name):
128         member_names = []
129         for item in cls.mapping:
130             if item['field_name'] == field_name and item['member_name']:
131                 member_names.append(item['member_name'])
132         return member_names
133 
134     def get_dict_output_field_name(cls, field_name, member_name):
135         for item in cls.mapping:
136             if item['field_name'] == field_name and item['member_name'] == member_name:
137                 return item['output_field_name']
138         return None
139 
140 
141 class JiraJQL(BaseHTTPQueryRunner):
142     noop_query = '{"queryType": "count"}'
143     response_error = "JIRA returned unexpected status code"
144     requires_authentication = True
145     url_title = 'JIRA URL'
146     username_title = 'Username'
147     password_title = 'Password'
148 
149     @classmethod
150     def name(cls):
151         return "JIRA (JQL)"
152 
153     def __init__(self, configuration):
154         super(JiraJQL, self).__init__(configuration)
155         self.syntax = 'json'
156 
157     def run_query(self, query, user):
158         jql_url = '{}/rest/api/2/search'.format(self.configuration["url"])
159 
160         try:
161             query = json_loads(query)
162             query_type = query.pop('queryType', 'select')
163             field_mapping = FieldMapping(query.pop('fieldMapping', {}))
164 
165             if query_type == 'count':
166                 query['maxResults'] = 1
167                 query['fields'] = ''
168             else:
169                 query['maxResults'] = query.get('maxResults', 1000)
170 
171             response, error = self.get_response(jql_url, params=query)
172             if error is not None:
173                 return None, error
174 
175             data = response.json()
176 
177             if query_type == 'count':
178                 results = parse_count(data)
179             else:
180                 results = parse_issues(data, field_mapping)
181                 index = data['startAt'] + data['maxResults']
182 
183                 while data['total'] > index:
184                     query['startAt'] = index
185                     response, error = self.get_response(jql_url, params=query)
186                     if error is not None:
187                         return None, error
188 
189                     data = response.json()
190                     index = data['startAt'] + data['maxResults']
191 
192                     addl_results = parse_issues(data, field_mapping)
193                     results.merge(addl_results)
194 
195             return results.to_json(), None
196         except KeyboardInterrupt:
197             return None, "Query cancelled by user."
198 
199 
200 register(JiraJQL)
201
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/redash/query_runner/jql.py b/redash/query_runner/jql.py
--- a/redash/query_runner/jql.py
+++ b/redash/query_runner/jql.py
@@ -144,7 +144,7 @@
     requires_authentication = True
     url_title = 'JIRA URL'
     username_title = 'Username'
-    password_title = 'Password'
+    password_title = 'API Token'
 
     @classmethod
     def name(cls):

{"golden_diff": "diff --git a/redash/query_runner/jql.py b/redash/query_runner/jql.py\n--- a/redash/query_runner/jql.py\n+++ b/redash/query_runner/jql.py\n@@ -144,7 +144,7 @@\n     requires_authentication = True\n     url_title = 'JIRA URL'\n     username_title = 'Username'\n-    password_title = 'Password'\n+    password_title = 'API Token'\n \n     @classmethod\n     def name(cls):\n", "issue": "JIRA setup: change password field name to \"API Token\"\nWhile a password can be used there, it's not recommended and eventually will be deprecated. \n", "before_files": [{"content": "import re\nfrom collections import OrderedDict\n\nfrom redash.query_runner import *\nfrom redash.utils import json_dumps, json_loads\n\n\n# TODO: make this more general and move into __init__.py\nclass ResultSet(object):\n    def __init__(self):\n        self.columns = OrderedDict()\n        self.rows = []\n\n    def add_row(self, row):\n        for key in row.keys():\n            self.add_column(key)\n\n        self.rows.append(row)\n\n    def add_column(self, column, column_type=TYPE_STRING):\n        if column not in self.columns:\n            self.columns[column] = {'name': column, 'type': column_type, 'friendly_name': column}\n\n    def to_json(self):\n        return json_dumps({'rows': self.rows, 'columns': self.columns.values()})\n\n    def merge(self, set):\n        self.rows = self.rows + set.rows\n\n\ndef parse_issue(issue, field_mapping):\n    result = OrderedDict()\n    result['key'] = issue['key']\n\n    for k, v in issue['fields'].iteritems():#\n        output_name = field_mapping.get_output_field_name(k)\n        member_names = field_mapping.get_dict_members(k)\n\n        if isinstance(v, dict):\n            if len(member_names) > 0:\n                # if field mapping with dict member mappings defined get value of each member\n                for member_name in member_names:\n                    if member_name in v:\n                        result[field_mapping.get_dict_output_field_name(k, member_name)] = v[member_name]\n\n            else:\n                # these special mapping rules are kept for backwards compatibility\n                if 'key' in v:\n                    result['{}_key'.format(output_name)] = v['key']\n                if 'name' in v:\n                    result['{}_name'.format(output_name)] = v['name']\n\n                if k in v:\n                    result[output_name] = v[k]\n\n                if 'watchCount' in v:\n                    result[output_name] = v['watchCount']\n\n        elif isinstance(v, list):\n            if len(member_names) > 0:\n                # if field mapping with dict member mappings defined get value of each member\n                for member_name in member_names:\n                    listValues = []\n                    for listItem in v:\n                        if isinstance(listItem, dict):\n                            if member_name in listItem:\n                                listValues.append(listItem[member_name])\n                    if len(listValues) > 0:\n                        result[field_mapping.get_dict_output_field_name(k, member_name)] = ','.join(listValues)\n\n            else:\n                # otherwise support list values only for non-dict items\n                listValues = []\n                for listItem in v:\n                    if not isinstance(listItem, dict):\n                        listValues.append(listItem)\n                if len(listValues) > 0:\n                    result[output_name] = ','.join(listValues)\n\n        else:\n            result[output_name] = v\n\n    return result\n\n\ndef parse_issues(data, field_mapping):\n    results = ResultSet()\n\n    for issue in data['issues']:\n        results.add_row(parse_issue(issue, field_mapping))\n\n    return results\n\n\ndef parse_count(data):\n    results = ResultSet()\n    results.add_row({'count': data['total']})\n    return results\n\n\nclass FieldMapping:\n\n    def __init__(cls, query_field_mapping):\n        cls.mapping = []\n        for k, v in query_field_mapping.iteritems():\n            field_name = k\n            member_name = None\n\n            # check for member name contained in field name\n            member_parser = re.search('(\\w+)\\.(\\w+)', k)\n            if (member_parser):\n                field_name = member_parser.group(1)\n                member_name = member_parser.group(2)\n\n            cls.mapping.append({\n                'field_name': field_name,\n                'member_name': member_name,\n                'output_field_name': v\n                })\n\n    def get_output_field_name(cls, field_name):\n        for item in cls.mapping:\n            if item['field_name'] == field_name and not item['member_name']:\n                return item['output_field_name']\n        return field_name\n\n    def get_dict_members(cls, field_name):\n        member_names = []\n        for item in cls.mapping:\n            if item['field_name'] == field_name and item['member_name']:\n                member_names.append(item['member_name'])\n        return member_names\n\n    def get_dict_output_field_name(cls, field_name, member_name):\n        for item in cls.mapping:\n            if item['field_name'] == field_name and item['member_name'] == member_name:\n                return item['output_field_name']\n        return None\n\n\nclass JiraJQL(BaseHTTPQueryRunner):\n    noop_query = '{\"queryType\": \"count\"}'\n    response_error = \"JIRA returned unexpected status code\"\n    requires_authentication = True\n    url_title = 'JIRA URL'\n    username_title = 'Username'\n    password_title = 'Password'\n\n    @classmethod\n    def name(cls):\n        return \"JIRA (JQL)\"\n\n    def __init__(self, configuration):\n        super(JiraJQL, self).__init__(configuration)\n        self.syntax = 'json'\n\n    def run_query(self, query, user):\n        jql_url = '{}/rest/api/2/search'.format(self.configuration[\"url\"])\n\n        try:\n            query = json_loads(query)\n            query_type = query.pop('queryType', 'select')\n            field_mapping = FieldMapping(query.pop('fieldMapping', {}))\n\n            if query_type == 'count':\n                query['maxResults'] = 1\n                query['fields'] = ''\n            else:\n                query['maxResults'] = query.get('maxResults', 1000)\n\n            response, error = self.get_response(jql_url, params=query)\n            if error is not None:\n                return None, error\n\n            data = response.json()\n\n            if query_type == 'count':\n                results = parse_count(data)\n            else:\n                results = parse_issues(data, field_mapping)\n                index = data['startAt'] + data['maxResults']\n\n                while data['total'] > index:\n                    query['startAt'] = index\n                    response, error = self.get_response(jql_url, params=query)\n                    if error is not None:\n                        return None, error\n\n                    data = response.json()\n                    index = data['startAt'] + data['maxResults']\n\n                    addl_results = parse_issues(data, field_mapping)\n                    results.merge(addl_results)\n\n            return results.to_json(), None\n        except KeyboardInterrupt:\n            return None, \"Query cancelled by user.\"\n\n\nregister(JiraJQL)\n", "path": "redash/query_runner/jql.py"}], "after_files": [{"content": "import re\nfrom collections import OrderedDict\n\nfrom redash.query_runner import *\nfrom redash.utils import json_dumps, json_loads\n\n\n# TODO: make this more general and move into __init__.py\nclass ResultSet(object):\n    def __init__(self):\n        self.columns = OrderedDict()\n        self.rows = []\n\n    def add_row(self, row):\n        for key in row.keys():\n            self.add_column(key)\n\n        self.rows.append(row)\n\n    def add_column(self, column, column_type=TYPE_STRING):\n        if column not in self.columns:\n            self.columns[column] = {'name': column, 'type': column_type, 'friendly_name': column}\n\n    def to_json(self):\n        return json_dumps({'rows': self.rows, 'columns': self.columns.values()})\n\n    def merge(self, set):\n        self.rows = self.rows + set.rows\n\n\ndef parse_issue(issue, field_mapping):\n    result = OrderedDict()\n    result['key'] = issue['key']\n\n    for k, v in issue['fields'].iteritems():#\n        output_name = field_mapping.get_output_field_name(k)\n        member_names = field_mapping.get_dict_members(k)\n\n        if isinstance(v, dict):\n            if len(member_names) > 0:\n                # if field mapping with dict member mappings defined get value of each member\n                for member_name in member_names:\n                    if member_name in v:\n                        result[field_mapping.get_dict_output_field_name(k, member_name)] = v[member_name]\n\n            else:\n                # these special mapping rules are kept for backwards compatibility\n                if 'key' in v:\n                    result['{}_key'.format(output_name)] = v['key']\n                if 'name' in v:\n                    result['{}_name'.format(output_name)] = v['name']\n\n                if k in v:\n                    result[output_name] = v[k]\n\n                if 'watchCount' in v:\n                    result[output_name] = v['watchCount']\n\n        elif isinstance(v, list):\n            if len(member_names) > 0:\n                # if field mapping with dict member mappings defined get value of each member\n                for member_name in member_names:\n                    listValues = []\n                    for listItem in v:\n                        if isinstance(listItem, dict):\n                            if member_name in listItem:\n                                listValues.append(listItem[member_name])\n                    if len(listValues) > 0:\n                        result[field_mapping.get_dict_output_field_name(k, member_name)] = ','.join(listValues)\n\n            else:\n                # otherwise support list values only for non-dict items\n                listValues = []\n                for listItem in v:\n                    if not isinstance(listItem, dict):\n                        listValues.append(listItem)\n                if len(listValues) > 0:\n                    result[output_name] = ','.join(listValues)\n\n        else:\n            result[output_name] = v\n\n    return result\n\n\ndef parse_issues(data, field_mapping):\n    results = ResultSet()\n\n    for issue in data['issues']:\n        results.add_row(parse_issue(issue, field_mapping))\n\n    return results\n\n\ndef parse_count(data):\n    results = ResultSet()\n    results.add_row({'count': data['total']})\n    return results\n\n\nclass FieldMapping:\n\n    def __init__(cls, query_field_mapping):\n        cls.mapping = []\n        for k, v in query_field_mapping.iteritems():\n            field_name = k\n            member_name = None\n\n            # check for member name contained in field name\n            member_parser = re.search('(\\w+)\\.(\\w+)', k)\n            if (member_parser):\n                field_name = member_parser.group(1)\n                member_name = member_parser.group(2)\n\n            cls.mapping.append({\n                'field_name': field_name,\n                'member_name': member_name,\n                'output_field_name': v\n                })\n\n    def get_output_field_name(cls, field_name):\n        for item in cls.mapping:\n            if item['field_name'] == field_name and not item['member_name']:\n                return item['output_field_name']\n        return field_name\n\n    def get_dict_members(cls, field_name):\n        member_names = []\n        for item in cls.mapping:\n            if item['field_name'] == field_name and item['member_name']:\n                member_names.append(item['member_name'])\n        return member_names\n\n    def get_dict_output_field_name(cls, field_name, member_name):\n        for item in cls.mapping:\n            if item['field_name'] == field_name and item['member_name'] == member_name:\n                return item['output_field_name']\n        return None\n\n\nclass JiraJQL(BaseHTTPQueryRunner):\n    noop_query = '{\"queryType\": \"count\"}'\n    response_error = \"JIRA returned unexpected status code\"\n    requires_authentication = True\n    url_title = 'JIRA URL'\n    username_title = 'Username'\n    password_title = 'API Token'\n\n    @classmethod\n    def name(cls):\n        return \"JIRA (JQL)\"\n\n    def __init__(self, configuration):\n        super(JiraJQL, self).__init__(configuration)\n        self.syntax = 'json'\n\n    def run_query(self, query, user):\n        jql_url = '{}/rest/api/2/search'.format(self.configuration[\"url\"])\n\n        try:\n            query = json_loads(query)\n            query_type = query.pop('queryType', 'select')\n            field_mapping = FieldMapping(query.pop('fieldMapping', {}))\n\n            if query_type == 'count':\n                query['maxResults'] = 1\n                query['fields'] = ''\n            else:\n                query['maxResults'] = query.get('maxResults', 1000)\n\n            response, error = self.get_response(jql_url, params=query)\n            if error is not None:\n                return None, error\n\n            data = response.json()\n\n            if query_type == 'count':\n                results = parse_count(data)\n            else:\n                results = parse_issues(data, field_mapping)\n                index = data['startAt'] + data['maxResults']\n\n                while data['total'] > index:\n                    query['startAt'] = index\n                    response, error = self.get_response(jql_url, params=query)\n                    if error is not None:\n                        return None, error\n\n                    data = response.json()\n                    index = data['startAt'] + data['maxResults']\n\n                    addl_results = parse_issues(data, field_mapping)\n                    results.merge(addl_results)\n\n            return results.to_json(), None\n        except KeyboardInterrupt:\n            return None, \"Query cancelled by user.\"\n\n\nregister(JiraJQL)\n", "path": "redash/query_runner/jql.py"}]}