mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 05:36:00 +00:00
feat: oracle parameters
This commit is contained in:
@@ -68,6 +68,29 @@ class Analyser extends DatabaseAnalyser {
|
||||
const routines = await this.analyserQuery('routines', ['procedures', 'functions'], {
|
||||
$owner: this.dbhan.database,
|
||||
});
|
||||
|
||||
const parameters = await this.analyserQuery('parameters', ['procedures', 'functions'], {
|
||||
$owner: this.dbhan.database,
|
||||
});
|
||||
console.dir(parameters, { depth: 4 });
|
||||
|
||||
const routineToParams = parameters.rows.reduce((acc, row) => {
|
||||
if (!acc[row.PURE_NAME]) acc[row.PURE_NAME] = [];
|
||||
|
||||
acc[row.PURE_NAME].push({
|
||||
pureName: row.PURE_NAME,
|
||||
parameterName: row.PARAMETER_NAME,
|
||||
dataType: row.DATA_TYPE,
|
||||
charMaxLength: row.CHAR_MAX,
|
||||
numericPrecision: row.NUMERIC_PRECISION,
|
||||
numericScale: row.NUMERIC_SCALE,
|
||||
parameterMode: row.PARAMETER_MODE,
|
||||
position: row.ORDINAL_POSITION ?? acc[row.PURE_NAME].length,
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
this.feedback({ analysingMessage: 'Loading indexes' });
|
||||
const indexes = await this.analyserQuery('indexes', ['tables'], { $owner: this.dbhan.database });
|
||||
this.feedback({ analysingMessage: 'Loading unique names' });
|
||||
@@ -177,6 +200,7 @@ class Analyser extends DatabaseAnalyser {
|
||||
// schemaName: proc.schema_name,
|
||||
createSql: `SET SQLTERMINATOR "/"\nCREATE ${proc.source_code}\n/\n`,
|
||||
contentHash: proc.hash_code,
|
||||
parameters: routineToParams[proc.pure_name],
|
||||
})),
|
||||
functions: routines.rows
|
||||
.filter(x => x.object_type == 'FUNCTION')
|
||||
@@ -186,6 +210,7 @@ class Analyser extends DatabaseAnalyser {
|
||||
pureName: func.pure_name,
|
||||
// schemaName: func.schema_name,
|
||||
contentHash: func.hash_code,
|
||||
parameters: routineToParams[func.pure_name],
|
||||
})),
|
||||
triggers: triggers.rows.map(row => ({
|
||||
pureName: row.TRIGGER_NAME,
|
||||
|
||||
@@ -5,6 +5,7 @@ const foreignKeys = require('./foreignKeys');
|
||||
const views = require('./views');
|
||||
const matviews = require('./matviews');
|
||||
const routines = require('./routines');
|
||||
const parameters = require('./parameters');
|
||||
const indexes = require('./indexes'); // use mysql
|
||||
const triggers = require('./triggers');
|
||||
//const indexcols = require('./indexcols');
|
||||
@@ -23,6 +24,7 @@ module.exports = {
|
||||
foreignKeys,
|
||||
views,
|
||||
routines,
|
||||
parameters,
|
||||
matviews,
|
||||
indexes,
|
||||
triggers,
|
||||
|
||||
22
plugins/dbgate-plugin-oracle/src/backend/sql/parameters.js
Normal file
22
plugins/dbgate-plugin-oracle/src/backend/sql/parameters.js
Normal file
@@ -0,0 +1,22 @@
|
||||
module.exports = `
|
||||
SELECT
|
||||
o.OBJECT_NAME AS pure_name,
|
||||
PACKAGE_NAME,
|
||||
ARGUMENT_NAME AS parameter_name,
|
||||
POSITION AS ordinal_position,
|
||||
DATA_TYPE AS data_type,
|
||||
CHAR_LENGTH AS char_max_length,
|
||||
DATA_PRECISION AS numeric_precision,
|
||||
DATA_SCALE AS numeric_scale,
|
||||
IN_OUT AS parameter_mode
|
||||
FROM
|
||||
all_objects o
|
||||
LEFT JOIN
|
||||
all_arguments a
|
||||
ON o.object_id = a.object_id
|
||||
WHERE
|
||||
o.object_type IN ('FUNCTION', 'PROCEDURE')
|
||||
AND o.OWNER = '$owner'
|
||||
ORDER BY
|
||||
POSITION;
|
||||
`;
|
||||
Reference in New Issue
Block a user