Updated variable name as per review comments.

This commit is contained in:
Pradip Parkale 2021-06-14 16:42:27 +05:30 committed by Akshay Joshi
parent 2fdde6218a
commit 3d685ef96c

View File

@ -201,17 +201,17 @@ def register_string_typecasters(connection):
def numeric_typecasters(results, conn_obj): def numeric_typecasters(results, conn_obj):
# This function is to convert pg types to numeic type caster # This function is to convert pg types to numeic type caster
data = [] numeric_cols = []
for obj_type in conn_obj.column_info: for obj_type in conn_obj.column_info:
if obj_type['type_code'] in TO_STRING_NUMERIC_DATATYPES: if obj_type['type_code'] in TO_STRING_NUMERIC_DATATYPES:
data.append(obj_type['name']) numeric_cols.append(obj_type['name'])
for result in results: for result in results:
for key, value in result.items(): for key, value in result.items():
if isinstance(result[key], if isinstance(result[key],
str) and key in data and not value.isdigit(): str) and key in numeric_cols and not value.isdigit():
result[key] = float(result[key]) result[key] = float(result[key])
elif isinstance(result[key], str) and key in data: elif isinstance(result[key], str) and key in numeric_cols:
result[key] = int(result[key]) result[key] = int(result[key])
return results return results