fix: remove redundant field from ParameterInfo

This commit is contained in:
Nybkox
2024-11-28 09:57:59 +01:00
parent 6b155083ef
commit 926949dc89
4 changed files with 23 additions and 24 deletions

View File

@@ -120,14 +120,10 @@ export interface ViewInfo extends SqlObjectInfo {
export interface ParameterInfo { export interface ParameterInfo {
objectId?: string | number; objectId?: string | number;
parentObjectId?: string | number; schemaName: string;
routineName?: string; parameterName?: string;
pureName: string; pureName: string;
dataType: string; dataType: string;
fullDataType: string;
maxLength?: number;
precision?: number;
scale?: string;
isOutputParameter?: boolean; isOutputParameter?: boolean;
} }
export interface ProcedureInfo extends SqlObjectInfo { export interface ProcedureInfo extends SqlObjectInfo {

View File

@@ -11,8 +11,8 @@
<AppObjectCore <AppObjectCore
{...$$restProps} {...$$restProps}
{data} {data}
title={data.pureName} title={data.parameterName}
extInfo={data.isOutputParameter ? `data.fullDataType OUT` : data.fullDataType} extInfo={data.isOutputParameter ? `${data.dataType} OUT` : data.dataType}
icon={'icon parameter'} icon={'icon parameter'}
disableHover disableHover
/> />

View File

@@ -197,34 +197,36 @@ class Analyser extends DatabaseAnalyser {
.filter(i => i.routine_type == 'PROCEDURE') .filter(i => i.routine_type == 'PROCEDURE')
.map(i => ({ .map(i => ({
objectId: 'procedures:' + i.specific_schema + '.' + i.routine_name + '@' + i.pure_name, objectId: 'procedures:' + i.specific_schema + '.' + i.routine_name + '@' + i.pure_name,
routineName: i.routine_name,
pureName: i.pure_name, pureName: i.pure_name,
parameterName: i.parameter_name,
dataType: i.data_type, dataType: i.data_type,
fullDataType: i.data_type,
isOutputParameter: i.is_output_parameter, isOutputParameter: i.is_output_parameter,
parameterMode: i.parameter_mode,
schemaName: i.schema_name,
})); }));
const procedureNameToParameters = procedurePerameters.reduce((acc, row) => { const procedureNameToParameters = procedurePerameters.reduce((acc, row) => {
if (!acc[row.routineName]) acc[row.routineName] = []; if (!acc[row.pureName]) acc[row.pureName] = [];
acc[row.routineName].push(row); acc[row.pureName].push(row);
return acc; return acc;
}, {}); }, {});
const fucntionPerameters = routineParametersRows.rows const functionParameters = routineParametersRows.rows
.filter(i => i.routine_type == 'FUNCTION') .filter(i => i.routine_type == 'FUNCTION')
.map(i => ({ .map(i => ({
objectId: 'functions:' + i.specific_schema + '.' + i.routine_name + '@' + i.pure_name, objectId: 'functions:' + i.specific_schema + '.' + i.routine_name + '@' + i.pure_name,
routineName: i.routine_name,
pureName: i.pure_name, pureName: i.pure_name,
parameterName: i.parameter_name,
dataType: i.data_type, dataType: i.data_type,
fullDataType: i.data_type,
isOutputParameter: i.is_output_parameter, isOutputParameter: i.is_output_parameter,
parameterMode: i.parameter_mode,
schemaName: i.schema_name,
})); }));
const functionNameToParameters = fucntionPerameters.reduce((acc, row) => { const functionNameToParameters = functionParameters.reduce((acc, row) => {
if (!acc[row.routineName]) acc[row.routineName] = []; if (!acc[row.pureName]) acc[row.pureName] = [];
acc[row.routineName].push(row); acc[row.pureName].push(row);
return acc; return acc;
}, {}); }, {});

View File

@@ -1,16 +1,17 @@
module.exports = ` module.exports = `
SELECT SELECT
proc.specific_schema AS specific_schema, proc.specific_schema AS schema_name,
proc.routine_name AS routine_name, proc.routine_name AS pure_name,
proc.routine_type as routine_type, proc.routine_type as routine_type,
args.parameter_name AS pure_name, args.parameter_name AS parameter_name,
args.parameter_mode, args.parameter_mode,
args.data_type AS data_type, args.data_type AS data_type,
args.ordinal_position AS parameter_index, args.ordinal_position AS parameter_index,
args.parameter_mode AS parameter_mode,
CASE CASE
WHEN args.parameter_mode IN ('OUT', 'INOUT') THEN TRUE WHEN args.parameter_mode IN ('OUT', 'INOUT') THEN TRUE
ELSE FALSE ELSE FALSE
END AS is_output_paramter END AS is_output_parameter
FROM FROM
information_schema.routines proc information_schema.routines proc
LEFT JOIN LEFT JOIN
@@ -21,7 +22,7 @@ WHERE
proc.routine_schema NOT IN ('pg_catalog', 'information_schema') -- Exclude system schemas proc.routine_schema NOT IN ('pg_catalog', 'information_schema') -- Exclude system schemas
AND proc.routine_type IN ('PROCEDURE', 'FUNCTION') -- Filter for procedures AND proc.routine_type IN ('PROCEDURE', 'FUNCTION') -- Filter for procedures
ORDER BY ORDER BY
specific_schema, schema_name,
routine_name, parameter_name,
args.ordinal_position; args.ordinal_position;
`; `;