Fixed an issue where CSV download quotes the numeric columns. Fixes #6341

This commit is contained in:
Pradip Parkale 2021-04-22 17:35:51 +05:30 committed by Akshay Joshi
parent 8ae8fea6d2
commit 5894001eb2
3 changed files with 14 additions and 1 deletions

View File

@ -17,4 +17,5 @@ Housekeeping
Bug fixes
*********
| `Issue #6341 <https://redmine.postgresql.org/issues/6341>`_ - Fixed an issue where CSV download quotes the numeric columns.
| `Issue #6385 <https://redmine.postgresql.org/issues/6385>`_ - Ensure that Backup and Restore should work on shared servers.

View File

@ -30,7 +30,7 @@ from pgadmin.utils.exception import ConnectionLost, CryptKeyMissing
from pgadmin.utils import get_complete_file_path
from ..abstract import BaseConnection
from .cursor import DictCursor
from .typecast import register_global_typecasters, \
from .typecast import register_float_typecasters, register_global_typecasters,\
register_string_typecasters, register_binary_typecasters, \
unregister_numeric_typecasters, \
register_array_to_string_typecasters, ALL_JSON_TYPES
@ -462,6 +462,7 @@ class Connection(BaseConnection):
self._set_auto_commit(kwargs)
register_string_typecasters(self.conn)
register_float_typecasters(self.conn)
if self.array_to_string:
register_array_to_string_typecasters(self.conn)
@ -911,6 +912,8 @@ WHERE db.datname = current_database()""")
# Registering back type caster for large size data types to string
# which was unregistered at starting
if any(type['type_code'] == 701 for type in self.column_info):
register_float_typecasters(self.conn)
register_string_typecasters(self.conn)
return True, gen

View File

@ -13,6 +13,7 @@ data types.
"""
from psycopg2 import STRING as _STRING
from psycopg2.extensions import FLOAT as _FLOAT
from psycopg2.extensions import DECIMAL as _DECIMAL, encodings
import psycopg2
from psycopg2.extras import Json as psycopg2_json
@ -203,6 +204,14 @@ def register_string_typecasters(connection):
psycopg2.extensions.register_type(unicode_array_type, connection)
def register_float_typecasters(connection):
# This function is to convert pg types into decimal type
string_type_to_float = \
psycopg2.extensions.new_type(TO_STRING_NUMERIC_DATATYPES,
'TYPECAST_TO_DECIMAL', _DECIMAL)
psycopg2.extensions.register_type(string_type_to_float, connection)
def register_binary_typecasters(connection):
psycopg2.extensions.register_type(
psycopg2.extensions.new_type(