mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
mysql - analyse views, procedures, functions
This commit is contained in:
parent
dc4fbe21de
commit
536ee6678f
@ -44,6 +44,8 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
||||
const columns = await this.driver.query(this.pool, this.createQuery('columns'));
|
||||
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys'));
|
||||
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys'));
|
||||
const views = await this.driver.query(this.pool, this.createQuery('views'));
|
||||
const programmables = await this.driver.query(this.pool, this.createQuery('programmables'));
|
||||
|
||||
return this.mergeAnalyseResult({
|
||||
tables: tables.rows.map((table) => ({
|
||||
@ -52,6 +54,12 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
||||
primaryKey: DatabaseAnalayser.extractPrimaryKeys(table, pkColumns.rows),
|
||||
foreignKeys: DatabaseAnalayser.extractForeignKeys(table, fkColumns.rows),
|
||||
})),
|
||||
views: views.rows.map((view) => ({
|
||||
...view,
|
||||
columns: columns.rows.filter((col) => col.pureName == view.pureName).map(getColumnInfo),
|
||||
})),
|
||||
procedures: programmables.rows.filter((x) => x.objectType == 'PROCEDURE').map(fp.omit(['objectType'])),
|
||||
functions: programmables.rows.filter((x) => x.objectType == 'FUNCTION').map(fp.omit(['objectType'])),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ const tables = require('./tables');
|
||||
const primaryKeys = require('./primaryKeys');
|
||||
const foreignKeys = require('./foreignKeys');
|
||||
const tableModifications = require('./tableModifications');
|
||||
const views = require('./views');
|
||||
const programmables = require('./programmables');
|
||||
|
||||
module.exports = {
|
||||
columns,
|
||||
@ -10,4 +12,6 @@ module.exports = {
|
||||
primaryKeys,
|
||||
foreignKeys,
|
||||
tableModifications,
|
||||
views,
|
||||
programmables,
|
||||
};
|
||||
|
8
packages/engines/mysql/sql/programmables.js
Normal file
8
packages/engines/mysql/sql/programmables.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = `
|
||||
select
|
||||
ROUTINE_NAME as pureName,
|
||||
ROUTINE_TYPE as objectType,
|
||||
ROUTINE_DEFINITION as createSql
|
||||
from information_schema.routines
|
||||
where ROUTINE_SCHEMA = '#DATABASE#'
|
||||
`;
|
@ -3,5 +3,5 @@ select
|
||||
TABLE_NAME as pureName,
|
||||
case when ENGINE='InnoDB' then CREATE_TIME else coalesce(UPDATE_TIME, CREATE_TIME) end as alterTime
|
||||
from information_schema.tables
|
||||
where TABLE_SCHEMA = '#DATABASE#' and TABLE_NAME =[OBJECT_NAME_CONDITION];
|
||||
where TABLE_SCHEMA = '#DATABASE#' and TABLE_TYPE='BASE TABLE' and TABLE_NAME =[OBJECT_NAME_CONDITION];
|
||||
`;
|
||||
|
7
packages/engines/mysql/sql/views.js
Normal file
7
packages/engines/mysql/sql/views.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = `
|
||||
select
|
||||
TABLE_NAME as pureName,
|
||||
VIEW_DEFINITION as createSql
|
||||
from information_schema.views
|
||||
where TABLE_SCHEMA = '#DATABASE#' and TABLE_NAME =[OBJECT_NAME_CONDITION];
|
||||
`;
|
Loading…
Reference in New Issue
Block a user