Fixed an issue where pgAdmin does not support pg_vector column length/precision. #8181

This commit is contained in:
Akshay Joshi 2025-02-12 16:14:31 +05:30
parent 58bb14253e
commit f63190dc93
5 changed files with 29 additions and 18 deletions

View File

@ -29,5 +29,6 @@ Housekeeping
Bug fixes Bug fixes
********* *********
| `Issue #8181 <https://github.com/pgadmin-org/pgadmin4/issues/8181>`_ - Fixed an issue where pgAdmin does not support pg_vector column length/precision.
| `Issue #8341 <https://github.com/pgadmin-org/pgadmin4/issues/8341>`_ - Fixed an issue where the query tool was not treating IDENTITY columns as columns with default values when inserting new rows. | `Issue #8341 <https://github.com/pgadmin-org/pgadmin4/issues/8341>`_ - Fixed an issue where the query tool was not treating IDENTITY columns as columns with default values when inserting new rows.
| `Issue #8410 <https://github.com/pgadmin-org/pgadmin4/issues/8410>`_ - Fixed Docker image entrypoint.sh email validation. | `Issue #8410 <https://github.com/pgadmin-org/pgadmin4/issues/8410>`_ - Fixed Docker image entrypoint.sh email validation.

View File

@ -441,7 +441,8 @@ def fetch_length_precision(data):
precision = False precision = False
if 'elemoid' in data: if 'elemoid' in data:
length, precision, _ = \ length, precision, _ = \
DataTypeReader.get_length_precision(data['elemoid']) DataTypeReader.get_length_precision(data['elemoid'],
data['typname'])
# Set length and precision to None # Set length and precision to None
data['attlen'] = None data['attlen'] = None

View File

@ -28,6 +28,7 @@ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
from pgadmin.utils.driver import get_driver from pgadmin.utils.driver import get_driver
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
from pgadmin.utils.constants import DATA_TYPE_WITH_LENGTH
class TypeModule(SchemaChildModule): class TypeModule(SchemaChildModule):
@ -436,7 +437,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
properties_list.append(typelist) properties_list.append(typelist)
is_tlength, is_precision, _ = \ is_tlength, is_precision, _ = \
self.get_length_precision(row.get('elemoid', None)) self.get_length_precision(row.get('elemoid', None),
row.get('typname', None))
# Split length, precision from type name for grid # Split length, precision from type name for grid
t_len, t_prec = DataTypeReader.parse_length_precision( t_len, t_prec = DataTypeReader.parse_length_precision(
@ -469,7 +471,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
:return: formatted response :return: formatted response
""" """
is_tlength, is_precision, _ = \ is_tlength, is_precision, _ = \
self.get_length_precision(data.get('elemoid', None)) self.get_length_precision(data.get('elemoid', None),
data.get('typname', None))
# Split length, precision from type name for grid # Split length, precision from type name for grid
t_len, t_prec = DataTypeReader.parse_length_precision( t_len, t_prec = DataTypeReader.parse_length_precision(
@ -676,8 +679,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
for row in rset['rows']: for row in rset['rows']:
# Check against PGOID for specific type # Check against PGOID for specific type
if row['elemoid']: if row['elemoid']:
if row['elemoid'] in (1560, 1561, 1562, 1563, 1042, 1043, if row['elemoid'] in DATA_TYPE_WITH_LENGTH or \
1014, 1015): row['typname'] in DATA_TYPE_WITH_LENGTH:
typeval = 'L' typeval = 'L'
elif row['elemoid'] in (1083, 1114, 1115, 1183, 1184, 1185, elif row['elemoid'] in (1083, 1114, 1115, 1183, 1184, 1185,
1186, 1187, 1266, 1270): 1186, 1187, 1266, 1270):

View File

@ -22,7 +22,8 @@ from config import PG_DEFAULT_DRIVER
from pgadmin.utils.constants import DATATYPE_TIME_WITH_TIMEZONE,\ from pgadmin.utils.constants import DATATYPE_TIME_WITH_TIMEZONE,\
DATATYPE_TIME_WITHOUT_TIMEZONE,\ DATATYPE_TIME_WITHOUT_TIMEZONE,\
DATATYPE_TIMESTAMP_WITH_TIMEZONE,\ DATATYPE_TIMESTAMP_WITH_TIMEZONE,\
DATATYPE_TIMESTAMP_WITHOUT_TIMEZONE DATATYPE_TIMESTAMP_WITHOUT_TIMEZONE,\
DATA_TYPE_WITH_LENGTH
class SchemaChildModule(CollectionNodeModule): class SchemaChildModule(CollectionNodeModule):
@ -173,7 +174,7 @@ class DataTypeReader:
# Check if the type will have length and precision or not # Check if the type will have length and precision or not
if row['elemoid']: if row['elemoid']:
length, precision, typeval = self.get_length_precision( length, precision, typeval = self.get_length_precision(
row['elemoid']) row['elemoid'], row['typname'])
min_val, max_val = DataTypeReader._types_length_checks( min_val, max_val = DataTypeReader._types_length_checks(
length, typeval, precision) length, typeval, precision)
@ -192,21 +193,16 @@ class DataTypeReader:
return True, res return True, res
@staticmethod @staticmethod
def get_length_precision(elemoid_or_name): def get_length_precision(elemoid_or_name, typname=None):
precision = False precision = False
length = False length = False
typeval = '' typeval = ''
# Check against PGOID/typename for specific type # Check against PGOID/typename for specific type
if elemoid_or_name: if elemoid_or_name:
if elemoid_or_name in (1560, 'bit', if (elemoid_or_name in DATA_TYPE_WITH_LENGTH or
1561, 'bit[]', typname is not None and
1562, 'varbit', 'bit varying', typname in DATA_TYPE_WITH_LENGTH):
1563, 'varbit[]', 'bit varying[]',
1042, 'bpchar', 'character',
1043, 'varchar', 'character varying',
1014, 'bpchar[]', 'character[]',
1015, 'varchar[]', 'character varying[]'):
typeval = 'L' typeval = 'L'
elif elemoid_or_name in (1083, 'time', elif elemoid_or_name in (1083, 'time',
DATATYPE_TIME_WITHOUT_TIMEZONE, DATATYPE_TIME_WITHOUT_TIMEZONE,
@ -267,7 +263,8 @@ class DataTypeReader:
name == DATATYPE_TIMESTAMP_WITH_TIMEZONE or name == DATATYPE_TIMESTAMP_WITH_TIMEZONE or
name == 'bit' or name == 'bit' or
name == 'bit varying' or name == 'bit varying' or
name == 'varbit' name == 'varbit' or name == 'vector' or name == 'halfvec' or
name == 'sparsevec'
): ):
_prec = 0 _prec = 0
_len = typmod _len = typmod

View File

@ -127,7 +127,6 @@ ACCESS_DENIED_MESSAGE = gettext(
"Access denied: Youre having limited access. Youre not allowed to " "Access denied: Youre having limited access. Youre not allowed to "
"Rename, Delete or Create any files/folders") "Rename, Delete or Create any files/folders")
KEY_RING_SERVICE_NAME = 'pgAdmin4' KEY_RING_SERVICE_NAME = 'pgAdmin4'
KEY_RING_USER_NAME = 'pgadmin4-master-password' KEY_RING_USER_NAME = 'pgadmin4-master-password'
KEY_RING_USERNAME_FORMAT = KEY_RING_SERVICE_NAME + '-{0}-{1}' KEY_RING_USERNAME_FORMAT = KEY_RING_SERVICE_NAME + '-{0}-{1}'
@ -150,3 +149,13 @@ IP_ADDRESS_STRING = '{}/{}'
TWO_PARAM_STRING = '{0}/{1}' TWO_PARAM_STRING = '{0}/{1}'
SERVER_NOT_FOUND = gettext("Could not find the specified server.") SERVER_NOT_FOUND = gettext("Could not find the specified server.")
SSL_MODES = ['prefer', 'require', 'verify-ca', 'verify-full'] SSL_MODES = ['prefer', 'require', 'verify-ca', 'verify-full']
DATA_TYPE_WITH_LENGTH = [1560, 'bit', 1561, 'bit[]',
1562, 'varbit', 'bit varying',
1563, 'varbit[]', 'bit varying[]',
1042, 'bpchar', 'character',
1043, 'varchar', 'character varying',
1014, 'bpchar[]', 'character[]',
1015, 'varchar[]', 'character varying[]',
'vector', 'vector[]', 'halfvec', 'halfvec[]',
'sparsevec', 'sparsevec[]']