We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
error running query : ** '>' is not supported between instance of NoneType and 'int'
Issue Summary:
Database = Oracle 12c

`select count(*) from table `

throwing the following error

`error running query : ** '>' is not supported between instance of NoneType and 'int'`

Redash v9.0.0-alpha(dev)




--- 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/oracle.py`
Content:
```
1 import logging
2 
3 from redash.utils import json_dumps, json_loads
4 from redash.query_runner import *
5 
6 try:
7     import cx_Oracle
8 
9     TYPES_MAP = {
10         cx_Oracle.DATETIME: TYPE_DATETIME,
11         cx_Oracle.CLOB: TYPE_STRING,
12         cx_Oracle.LOB: TYPE_STRING,
13         cx_Oracle.FIXED_CHAR: TYPE_STRING,
14         cx_Oracle.FIXED_NCHAR: TYPE_STRING,
15         cx_Oracle.INTERVAL: TYPE_DATETIME,
16         cx_Oracle.LONG_STRING: TYPE_STRING,
17         cx_Oracle.NATIVE_FLOAT: TYPE_FLOAT,
18         cx_Oracle.NCHAR: TYPE_STRING,
19         cx_Oracle.NUMBER: TYPE_FLOAT,
20         cx_Oracle.ROWID: TYPE_INTEGER,
21         cx_Oracle.STRING: TYPE_STRING,
22         cx_Oracle.TIMESTAMP: TYPE_DATETIME,
23     }
24 
25     ENABLED = True
26 except ImportError:
27     ENABLED = False
28 
29 logger = logging.getLogger(__name__)
30 
31 
32 class Oracle(BaseSQLQueryRunner):
33     noop_query = "SELECT 1 FROM dual"
34 
35     @classmethod
36     def get_col_type(cls, col_type, scale):
37         if col_type == cx_Oracle.NUMBER:
38             return TYPE_FLOAT if scale > 0 else TYPE_INTEGER
39         else:
40             return TYPES_MAP.get(col_type, None)
41 
42     @classmethod
43     def enabled(cls):
44         return ENABLED
45 
46     @classmethod
47     def configuration_schema(cls):
48         return {
49             "type": "object",
50             "properties": {
51                 "user": {"type": "string"},
52                 "password": {"type": "string"},
53                 "host": {"type": "string"},
54                 "port": {"type": "number"},
55                 "servicename": {"type": "string", "title": "DSN Service Name"},
56             },
57             "required": ["servicename", "user", "password", "host", "port"],
58             "secret": ["password"],
59         }
60 
61     @classmethod
62     def type(cls):
63         return "oracle"
64 
65     def __init__(self, configuration):
66         super(Oracle, self).__init__(configuration)
67 
68         dsn = cx_Oracle.makedsn(
69             self.configuration["host"],
70             self.configuration["port"],
71             service_name=self.configuration["servicename"],
72         )
73 
74         self.connection_string = "{}/{}@{}".format(
75             self.configuration["user"], self.configuration["password"], dsn
76         )
77 
78     def _get_tables(self, schema):
79         query = """
80         SELECT
81             all_tab_cols.OWNER,
82             all_tab_cols.TABLE_NAME,
83             all_tab_cols.COLUMN_NAME
84         FROM all_tab_cols
85         WHERE all_tab_cols.OWNER NOT IN('SYS','SYSTEM','ORDSYS','CTXSYS','WMSYS','MDSYS','ORDDATA','XDB','OUTLN','DMSYS','DSSYS','EXFSYS','LBACSYS','TSMSYS')
86         """
87 
88         results, error = self.run_query(query, None)
89 
90         if error is not None:
91             raise Exception("Failed getting schema.")
92 
93         results = json_loads(results)
94 
95         for row in results["rows"]:
96             if row["OWNER"] != None:
97                 table_name = "{}.{}".format(row["OWNER"], row["TABLE_NAME"])
98             else:
99                 table_name = row["TABLE_NAME"]
100 
101             if table_name not in schema:
102                 schema[table_name] = {"name": table_name, "columns": []}
103 
104             schema[table_name]["columns"].append(row["COLUMN_NAME"])
105 
106         return list(schema.values())
107 
108     @classmethod
109     def _convert_number(cls, value):
110         try:
111             return int(value)
112         except:
113             return value
114 
115     @classmethod
116     def output_handler(cls, cursor, name, default_type, length, precision, scale):
117         if default_type in (cx_Oracle.CLOB, cx_Oracle.LOB):
118             return cursor.var(cx_Oracle.LONG_STRING, 80000, cursor.arraysize)
119 
120         if default_type in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR):
121             return cursor.var(str, length, cursor.arraysize)
122 
123         if default_type == cx_Oracle.NUMBER:
124             if scale <= 0:
125                 return cursor.var(
126                     cx_Oracle.STRING,
127                     255,
128                     outconverter=Oracle._convert_number,
129                     arraysize=cursor.arraysize,
130                 )
131 
132     def run_query(self, query, user):
133         connection = cx_Oracle.connect(self.connection_string)
134         connection.outputtypehandler = Oracle.output_handler
135 
136         cursor = connection.cursor()
137 
138         try:
139             cursor.execute(query)
140             rows_count = cursor.rowcount
141             if cursor.description is not None:
142                 columns = self.fetch_columns(
143                     [
144                         (i[0], Oracle.get_col_type(i[1], i[5]))
145                         for i in cursor.description
146                     ]
147                 )
148                 rows = [
149                     dict(zip((column["name"] for column in columns), row))
150                     for row in cursor
151                 ]
152                 data = {"columns": columns, "rows": rows}
153                 error = None
154                 json_data = json_dumps(data)
155             else:
156                 columns = [{"name": "Row(s) Affected", "type": "TYPE_INTEGER"}]
157                 rows = [{"Row(s) Affected": rows_count}]
158                 data = {"columns": columns, "rows": rows}
159                 json_data = json_dumps(data)
160                 connection.commit()
161         except cx_Oracle.DatabaseError as err:
162             error = "Query failed. {}.".format(str(err))
163             json_data = None
164         except KeyboardInterrupt:
165             connection.cancel()
166             error = "Query cancelled by user."
167             json_data = None
168         finally:
169             connection.close()
170 
171         return json_data, error
172 
173 
174 register(Oracle)
175
```
--- 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/oracle.py b/redash/query_runner/oracle.py
--- a/redash/query_runner/oracle.py
+++ b/redash/query_runner/oracle.py
@@ -35,7 +35,11 @@
     @classmethod
     def get_col_type(cls, col_type, scale):
         if col_type == cx_Oracle.NUMBER:
-            return TYPE_FLOAT if scale > 0 else TYPE_INTEGER
+            if scale is None:
+                return TYPE_INTEGER
+            if scale > 0:
+                return TYPE_FLOAT
+            return TYPE_INTEGER
         else:
             return TYPES_MAP.get(col_type, None)

{"golden_diff": "diff --git a/redash/query_runner/oracle.py b/redash/query_runner/oracle.py\n--- a/redash/query_runner/oracle.py\n+++ b/redash/query_runner/oracle.py\n@@ -35,7 +35,11 @@\n     @classmethod\n     def get_col_type(cls, col_type, scale):\n         if col_type == cx_Oracle.NUMBER:\n-            return TYPE_FLOAT if scale > 0 else TYPE_INTEGER\n+            if scale is None:\n+                return TYPE_INTEGER\n+            if scale > 0:\n+                return TYPE_FLOAT\n+            return TYPE_INTEGER\n         else:\n             return TYPES_MAP.get(col_type, None)\n", "issue": "error running query : ** '>' is not supported between instance of NoneType and 'int'\nIssue Summary:\r\nDatabase = Oracle 12c\r\n\r\n`select count(*) from table `\r\n\r\nthrowing the following error\r\n\r\n`error running query : ** '>' is not supported between instance of NoneType and 'int'`\r\n\r\nRedash v9.0.0-alpha(dev)\r\n\r\n\r\n\n", "before_files": [{"content": "import logging\n\nfrom redash.utils import json_dumps, json_loads\nfrom redash.query_runner import *\n\ntry:\n    import cx_Oracle\n\n    TYPES_MAP = {\n        cx_Oracle.DATETIME: TYPE_DATETIME,\n        cx_Oracle.CLOB: TYPE_STRING,\n        cx_Oracle.LOB: TYPE_STRING,\n        cx_Oracle.FIXED_CHAR: TYPE_STRING,\n        cx_Oracle.FIXED_NCHAR: TYPE_STRING,\n        cx_Oracle.INTERVAL: TYPE_DATETIME,\n        cx_Oracle.LONG_STRING: TYPE_STRING,\n        cx_Oracle.NATIVE_FLOAT: TYPE_FLOAT,\n        cx_Oracle.NCHAR: TYPE_STRING,\n        cx_Oracle.NUMBER: TYPE_FLOAT,\n        cx_Oracle.ROWID: TYPE_INTEGER,\n        cx_Oracle.STRING: TYPE_STRING,\n        cx_Oracle.TIMESTAMP: TYPE_DATETIME,\n    }\n\n    ENABLED = True\nexcept ImportError:\n    ENABLED = False\n\nlogger = logging.getLogger(__name__)\n\n\nclass Oracle(BaseSQLQueryRunner):\n    noop_query = \"SELECT 1 FROM dual\"\n\n    @classmethod\n    def get_col_type(cls, col_type, scale):\n        if col_type == cx_Oracle.NUMBER:\n            return TYPE_FLOAT if scale > 0 else TYPE_INTEGER\n        else:\n            return TYPES_MAP.get(col_type, None)\n\n    @classmethod\n    def enabled(cls):\n        return ENABLED\n\n    @classmethod\n    def configuration_schema(cls):\n        return {\n            \"type\": \"object\",\n            \"properties\": {\n                \"user\": {\"type\": \"string\"},\n                \"password\": {\"type\": \"string\"},\n                \"host\": {\"type\": \"string\"},\n                \"port\": {\"type\": \"number\"},\n                \"servicename\": {\"type\": \"string\", \"title\": \"DSN Service Name\"},\n            },\n            \"required\": [\"servicename\", \"user\", \"password\", \"host\", \"port\"],\n            \"secret\": [\"password\"],\n        }\n\n    @classmethod\n    def type(cls):\n        return \"oracle\"\n\n    def __init__(self, configuration):\n        super(Oracle, self).__init__(configuration)\n\n        dsn = cx_Oracle.makedsn(\n            self.configuration[\"host\"],\n            self.configuration[\"port\"],\n            service_name=self.configuration[\"servicename\"],\n        )\n\n        self.connection_string = \"{}/{}@{}\".format(\n            self.configuration[\"user\"], self.configuration[\"password\"], dsn\n        )\n\n    def _get_tables(self, schema):\n        query = \"\"\"\n        SELECT\n            all_tab_cols.OWNER,\n            all_tab_cols.TABLE_NAME,\n            all_tab_cols.COLUMN_NAME\n        FROM all_tab_cols\n        WHERE all_tab_cols.OWNER NOT IN('SYS','SYSTEM','ORDSYS','CTXSYS','WMSYS','MDSYS','ORDDATA','XDB','OUTLN','DMSYS','DSSYS','EXFSYS','LBACSYS','TSMSYS')\n        \"\"\"\n\n        results, error = self.run_query(query, None)\n\n        if error is not None:\n            raise Exception(\"Failed getting schema.\")\n\n        results = json_loads(results)\n\n        for row in results[\"rows\"]:\n            if row[\"OWNER\"] != None:\n                table_name = \"{}.{}\".format(row[\"OWNER\"], row[\"TABLE_NAME\"])\n            else:\n                table_name = row[\"TABLE_NAME\"]\n\n            if table_name not in schema:\n                schema[table_name] = {\"name\": table_name, \"columns\": []}\n\n            schema[table_name][\"columns\"].append(row[\"COLUMN_NAME\"])\n\n        return list(schema.values())\n\n    @classmethod\n    def _convert_number(cls, value):\n        try:\n            return int(value)\n        except:\n            return value\n\n    @classmethod\n    def output_handler(cls, cursor, name, default_type, length, precision, scale):\n        if default_type in (cx_Oracle.CLOB, cx_Oracle.LOB):\n            return cursor.var(cx_Oracle.LONG_STRING, 80000, cursor.arraysize)\n\n        if default_type in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR):\n            return cursor.var(str, length, cursor.arraysize)\n\n        if default_type == cx_Oracle.NUMBER:\n            if scale <= 0:\n                return cursor.var(\n                    cx_Oracle.STRING,\n                    255,\n                    outconverter=Oracle._convert_number,\n                    arraysize=cursor.arraysize,\n                )\n\n    def run_query(self, query, user):\n        connection = cx_Oracle.connect(self.connection_string)\n        connection.outputtypehandler = Oracle.output_handler\n\n        cursor = connection.cursor()\n\n        try:\n            cursor.execute(query)\n            rows_count = cursor.rowcount\n            if cursor.description is not None:\n                columns = self.fetch_columns(\n                    [\n                        (i[0], Oracle.get_col_type(i[1], i[5]))\n                        for i in cursor.description\n                    ]\n                )\n                rows = [\n                    dict(zip((column[\"name\"] for column in columns), row))\n                    for row in cursor\n                ]\n                data = {\"columns\": columns, \"rows\": rows}\n                error = None\n                json_data = json_dumps(data)\n            else:\n                columns = [{\"name\": \"Row(s) Affected\", \"type\": \"TYPE_INTEGER\"}]\n                rows = [{\"Row(s) Affected\": rows_count}]\n                data = {\"columns\": columns, \"rows\": rows}\n                json_data = json_dumps(data)\n                connection.commit()\n        except cx_Oracle.DatabaseError as err:\n            error = \"Query failed. {}.\".format(str(err))\n            json_data = None\n        except KeyboardInterrupt:\n            connection.cancel()\n            error = \"Query cancelled by user.\"\n            json_data = None\n        finally:\n            connection.close()\n\n        return json_data, error\n\n\nregister(Oracle)\n", "path": "redash/query_runner/oracle.py"}], "after_files": [{"content": "import logging\n\nfrom redash.utils import json_dumps, json_loads\nfrom redash.query_runner import *\n\ntry:\n    import cx_Oracle\n\n    TYPES_MAP = {\n        cx_Oracle.DATETIME: TYPE_DATETIME,\n        cx_Oracle.CLOB: TYPE_STRING,\n        cx_Oracle.LOB: TYPE_STRING,\n        cx_Oracle.FIXED_CHAR: TYPE_STRING,\n        cx_Oracle.FIXED_NCHAR: TYPE_STRING,\n        cx_Oracle.INTERVAL: TYPE_DATETIME,\n        cx_Oracle.LONG_STRING: TYPE_STRING,\n        cx_Oracle.NATIVE_FLOAT: TYPE_FLOAT,\n        cx_Oracle.NCHAR: TYPE_STRING,\n        cx_Oracle.NUMBER: TYPE_FLOAT,\n        cx_Oracle.ROWID: TYPE_INTEGER,\n        cx_Oracle.STRING: TYPE_STRING,\n        cx_Oracle.TIMESTAMP: TYPE_DATETIME,\n    }\n\n    ENABLED = True\nexcept ImportError:\n    ENABLED = False\n\nlogger = logging.getLogger(__name__)\n\n\nclass Oracle(BaseSQLQueryRunner):\n    noop_query = \"SELECT 1 FROM dual\"\n\n    @classmethod\n    def get_col_type(cls, col_type, scale):\n        if col_type == cx_Oracle.NUMBER:\n            if scale is None:\n                return TYPE_INTEGER\n            if scale > 0:\n                return TYPE_FLOAT\n            return TYPE_INTEGER\n        else:\n            return TYPES_MAP.get(col_type, None)\n\n    @classmethod\n    def enabled(cls):\n        return ENABLED\n\n    @classmethod\n    def configuration_schema(cls):\n        return {\n            \"type\": \"object\",\n            \"properties\": {\n                \"user\": {\"type\": \"string\"},\n                \"password\": {\"type\": \"string\"},\n                \"host\": {\"type\": \"string\"},\n                \"port\": {\"type\": \"number\"},\n                \"servicename\": {\"type\": \"string\", \"title\": \"DSN Service Name\"},\n            },\n            \"required\": [\"servicename\", \"user\", \"password\", \"host\", \"port\"],\n            \"secret\": [\"password\"],\n        }\n\n    @classmethod\n    def type(cls):\n        return \"oracle\"\n\n    def __init__(self, configuration):\n        super(Oracle, self).__init__(configuration)\n\n        dsn = cx_Oracle.makedsn(\n            self.configuration[\"host\"],\n            self.configuration[\"port\"],\n            service_name=self.configuration[\"servicename\"],\n        )\n\n        self.connection_string = \"{}/{}@{}\".format(\n            self.configuration[\"user\"], self.configuration[\"password\"], dsn\n        )\n\n    def _get_tables(self, schema):\n        query = \"\"\"\n        SELECT\n            all_tab_cols.OWNER,\n            all_tab_cols.TABLE_NAME,\n            all_tab_cols.COLUMN_NAME\n        FROM all_tab_cols\n        WHERE all_tab_cols.OWNER NOT IN('SYS','SYSTEM','ORDSYS','CTXSYS','WMSYS','MDSYS','ORDDATA','XDB','OUTLN','DMSYS','DSSYS','EXFSYS','LBACSYS','TSMSYS')\n        \"\"\"\n\n        results, error = self.run_query(query, None)\n\n        if error is not None:\n            raise Exception(\"Failed getting schema.\")\n\n        results = json_loads(results)\n\n        for row in results[\"rows\"]:\n            if row[\"OWNER\"] != None:\n                table_name = \"{}.{}\".format(row[\"OWNER\"], row[\"TABLE_NAME\"])\n            else:\n                table_name = row[\"TABLE_NAME\"]\n\n            if table_name not in schema:\n                schema[table_name] = {\"name\": table_name, \"columns\": []}\n\n            schema[table_name][\"columns\"].append(row[\"COLUMN_NAME\"])\n\n        return list(schema.values())\n\n    @classmethod\n    def _convert_number(cls, value):\n        try:\n            return int(value)\n        except:\n            return value\n\n    @classmethod\n    def output_handler(cls, cursor, name, default_type, length, precision, scale):\n        if default_type in (cx_Oracle.CLOB, cx_Oracle.LOB):\n            return cursor.var(cx_Oracle.LONG_STRING, 80000, cursor.arraysize)\n\n        if default_type in (cx_Oracle.STRING, cx_Oracle.FIXED_CHAR):\n            return cursor.var(str, length, cursor.arraysize)\n\n        if default_type == cx_Oracle.NUMBER:\n            if scale <= 0:\n                return cursor.var(\n                    cx_Oracle.STRING,\n                    255,\n                    outconverter=Oracle._convert_number,\n                    arraysize=cursor.arraysize,\n                )\n\n    def run_query(self, query, user):\n        connection = cx_Oracle.connect(self.connection_string)\n        connection.outputtypehandler = Oracle.output_handler\n\n        cursor = connection.cursor()\n\n        try:\n            cursor.execute(query)\n            rows_count = cursor.rowcount\n            if cursor.description is not None:\n                columns = self.fetch_columns(\n                    [\n                        (i[0], Oracle.get_col_type(i[1], i[5]))\n                        for i in cursor.description\n                    ]\n                )\n                rows = [\n                    dict(zip((column[\"name\"] for column in columns), row))\n                    for row in cursor\n                ]\n                data = {\"columns\": columns, \"rows\": rows}\n                error = None\n                json_data = json_dumps(data)\n            else:\n                columns = [{\"name\": \"Row(s) Affected\", \"type\": \"TYPE_INTEGER\"}]\n                rows = [{\"Row(s) Affected\": rows_count}]\n                data = {\"columns\": columns, \"rows\": rows}\n                json_data = json_dumps(data)\n                connection.commit()\n        except cx_Oracle.DatabaseError as err:\n            error = \"Query failed. {}.\".format(str(err))\n            json_data = None\n        except KeyboardInterrupt:\n            connection.cancel()\n            error = \"Query cancelled by user.\"\n            json_data = None\n        finally:\n            connection.close()\n\n        return json_data, error\n\n\nregister(Oracle)\n", "path": "redash/query_runner/oracle.py"}]}