mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Properly quote type names in RE-SQL for tables. Fixes #1863
This commit is contained in:
parent
da3a37ab19
commit
aef508ff91
@ -275,6 +275,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
self.manager = driver.connection_manager(kwargs['sid'])
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
self.qtIdent = driver.qtIdent
|
||||
self.qtTypeIdent = driver.qtTypeIdent
|
||||
# We need datlastsysoid to check if current table is system table
|
||||
self.datlastsysoid = self.manager.db_info[
|
||||
did
|
||||
@ -681,7 +682,13 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
|
||||
edit_types_list = list()
|
||||
# We will need present type in edit mode
|
||||
edit_types_list.append(present_type)
|
||||
|
||||
if column['typnspname'] == "pg_catalog" or column['typnspname'] == "public":
|
||||
edit_types_list.append(present_type)
|
||||
else:
|
||||
t = self.qtTypeIdent(self.conn, column['typnspname'], present_type)
|
||||
edit_types_list.append(t)
|
||||
column['cltype'] = t
|
||||
|
||||
if int(is_reference) == 0:
|
||||
SQL = render_template("/".join([self.column_template_path,
|
||||
@ -711,10 +718,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
if isArray:
|
||||
column['cltype'] += "[]"
|
||||
|
||||
if column['typnspname'] != 'pg_catalog':
|
||||
column['cltype'] = self.qtIdent(self.conn, column['typnspname']) \
|
||||
+ '.' + column['cltype']
|
||||
|
||||
if 'indkey' in column:
|
||||
# Current column
|
||||
attnum = str(column['attnum'])
|
||||
|
@ -199,6 +199,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
)
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
self.qtIdent = driver.qtIdent
|
||||
self.qtTypeIdent = driver.qtTypeIdent
|
||||
|
||||
# Set the template path for the SQL scripts
|
||||
if self.manager.version >= 90200:
|
||||
@ -417,7 +418,12 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
edit_types_list = list()
|
||||
# We will need present type in edit mode
|
||||
edit_types_list.append(present_type)
|
||||
if data['typnspname'] == "pg_catalog" or data['typnspname'] == "public":
|
||||
edit_types_list.append(present_type)
|
||||
else:
|
||||
t = self.qtTypeIdent(self.conn, data['typnspname'], present_type)
|
||||
edit_types_list.append(t)
|
||||
data['cltype'] = t
|
||||
|
||||
if int(is_reference) == 0:
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
@ -447,10 +453,6 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
if isArray:
|
||||
data['cltype'] += "[]"
|
||||
|
||||
if data['typnspname'] != 'pg_catalog':
|
||||
data['cltype'] = self.qtIdent(self.conn, data['typnspname'])\
|
||||
+ '.' + data['cltype']
|
||||
|
||||
return data
|
||||
|
||||
@check_precondition
|
||||
|
@ -302,8 +302,8 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
' <div class="col-md-4">',
|
||||
' <label class="control-label"><%-column_label%></label>',
|
||||
' </div>',
|
||||
' <div class="col-md-4" header="local_column"></div>',
|
||||
' <div class="col-md-4">',
|
||||
' <div class="col-md-6" header="local_column"></div>',
|
||||
' <div class="col-md-2">',
|
||||
' <button class="btn-sm btn-default add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> ></button>',
|
||||
' </div>',
|
||||
' </div>',
|
||||
@ -311,13 +311,13 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
' <div class="col-md-4">',
|
||||
' <label class="control-label"><%-references_label%></label>',
|
||||
' </div>',
|
||||
' <div class="col-md-4" header="references"></div>',
|
||||
' <div class="col-md-6" header="references"></div>',
|
||||
' </div>',
|
||||
' <div class="row">',
|
||||
' <div class="col-md-4">',
|
||||
' <label class="control-label"><%-referenced_label%></label>',
|
||||
' </div>',
|
||||
' <div class="col-md-4" header="referenced"></div>',
|
||||
' <div class="col-md-6" header="referenced"></div>',
|
||||
' </div>',
|
||||
' </div>',
|
||||
'</div>',].join("\n")
|
||||
|
@ -14,7 +14,7 @@ import json
|
||||
from flask import render_template
|
||||
from pgadmin.browser.collection import CollectionNodeModule
|
||||
from pgadmin.utils.ajax import internal_server_error
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
|
||||
class SchemaChildModule(CollectionNodeModule):
|
||||
"""
|
||||
@ -134,14 +134,8 @@ class DataTypeReader:
|
||||
else:
|
||||
max_val = 10
|
||||
|
||||
# If schema is public, prefix it. Otherwise, we should already have it.
|
||||
if row['nspname'] == 'public':
|
||||
rtn_type = "public." + row['typname']
|
||||
else:
|
||||
rtn_type = row['typname']
|
||||
|
||||
res.append({
|
||||
'label': rtn_type, 'value': rtn_type,
|
||||
'label': row['typname'], 'value': row['typname'],
|
||||
'typval': typeval, 'precision': precision,
|
||||
'length': length, 'min_val': min_val, 'max_val': max_val,
|
||||
'is_collatable': row['is_collatable']
|
||||
@ -243,6 +237,7 @@ class DataTypeReader:
|
||||
else:
|
||||
return name + length + array
|
||||
|
||||
|
||||
def trigger_definition(data):
|
||||
"""
|
||||
This function will set the trigger definition details from the raw data
|
||||
|
Loading…
Reference in New Issue
Block a user