mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixes
This commit is contained in:
parent
abf7ad478d
commit
eaaa7beaa1
@ -147,12 +147,12 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
|||||||
if (x.objectType == 'VIEW') return { ...x, objectTypeField: 'views' };
|
if (x.objectType == 'VIEW') return { ...x, objectTypeField: 'views' };
|
||||||
return null;
|
return null;
|
||||||
}),
|
}),
|
||||||
procedureModificationsQueryData.rows.map((x) => ({
|
...procedureModificationsQueryData.rows.map((x) => ({
|
||||||
objectTypeField: 'procedures',
|
objectTypeField: 'procedures',
|
||||||
modifyDate: x.Modified,
|
modifyDate: x.Modified,
|
||||||
pureName: x.Name,
|
pureName: x.Name,
|
||||||
})),
|
})),
|
||||||
functionModificationsQueryData.rows.map((x) => ({
|
...functionModificationsQueryData.rows.map((x) => ({
|
||||||
objectTypeField: 'functions',
|
objectTypeField: 'functions',
|
||||||
modifyDate: x.Modified,
|
modifyDate: x.Modified,
|
||||||
pureName: x.Name,
|
pureName: x.Name,
|
||||||
@ -160,6 +160,10 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// console.log('allModifications', allModifications);
|
// console.log('allModifications', allModifications);
|
||||||
|
// console.log(
|
||||||
|
// 'DATES',
|
||||||
|
// this.structure.procedures.map((x) => x.modifyDate)
|
||||||
|
// );
|
||||||
// console.log('MOD - SRC', modifications);
|
// console.log('MOD - SRC', modifications);
|
||||||
// console.log(
|
// console.log(
|
||||||
// 'MODs',
|
// 'MODs',
|
||||||
@ -176,6 +180,8 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
|||||||
// object not modified
|
// object not modified
|
||||||
if (obj && Math.abs(new Date(modifyDate).getTime() - new Date(obj.modifyDate).getTime()) < 1000) return null;
|
if (obj && Math.abs(new Date(modifyDate).getTime() - new Date(obj.modifyDate).getTime()) < 1000) return null;
|
||||||
|
|
||||||
|
// console.log('MODIFICATION OF ', field, pureName, modifyDate, obj.modifyDate);
|
||||||
|
|
||||||
/** @type {import('@dbgate/types').DatabaseModification} */
|
/** @type {import('@dbgate/types').DatabaseModification} */
|
||||||
const action = obj
|
const action = obj
|
||||||
? {
|
? {
|
||||||
|
@ -118,6 +118,16 @@ const driver = {
|
|||||||
const analyser = new MySqlAnalyser(pool, this);
|
const analyser = new MySqlAnalyser(pool, this);
|
||||||
return analyser.incrementalAnalysis(structure);
|
return analyser.incrementalAnalysis(structure);
|
||||||
},
|
},
|
||||||
|
async analyseSingleObject(pool, name, typeField = 'tables') {
|
||||||
|
const analyser = new MySqlAnalyser(pool, this);
|
||||||
|
analyser.singleObjectFilter = { ...name, typeField };
|
||||||
|
const res = await analyser.fullAnalysis();
|
||||||
|
return res.tables[0];
|
||||||
|
},
|
||||||
|
// @ts-ignore
|
||||||
|
analyseSingleTable(pool, name) {
|
||||||
|
return this.analyseSingleObject(pool, name, 'tables');
|
||||||
|
},
|
||||||
async listDatabases(connection) {
|
async listDatabases(connection) {
|
||||||
const { rows } = await this.query(connection, 'show databases');
|
const { rows } = await this.query(connection, 'show databases');
|
||||||
return rows.map((x) => ({ name: x.Database }));
|
return rows.map((x) => ({ name: x.Database }));
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SHOW PROCEDURE STATUS WHERE Db = '#DATABASE#'
|
SHOW FUNCTION STATUS WHERE Db = '#DATABASE#'
|
||||||
`;
|
`;
|
||||||
|
@ -2,7 +2,7 @@ module.exports = `
|
|||||||
select
|
select
|
||||||
ROUTINE_NAME as pureName,
|
ROUTINE_NAME as pureName,
|
||||||
ROUTINE_TYPE as objectType,
|
ROUTINE_TYPE as objectType,
|
||||||
LAST_ALTERED as modifyDate,
|
COALESCE(LAST_ALTERED, CREATED) as modifyDate,
|
||||||
ROUTINE_DEFINITION as createSql
|
ROUTINE_DEFINITION as createSql
|
||||||
from information_schema.routines
|
from information_schema.routines
|
||||||
where ROUTINE_SCHEMA = '#DATABASE#' and ROUTINE_NAME =[OBJECT_NAME_CONDITION]
|
where ROUTINE_SCHEMA = '#DATABASE#' and ROUTINE_NAME =[OBJECT_NAME_CONDITION]
|
||||||
|
@ -40,7 +40,7 @@ function useSqlTemplate(sqlTemplate, props) {
|
|||||||
if (sqlTemplate == 'CREATE OBJECT') {
|
if (sqlTemplate == 'CREATE OBJECT') {
|
||||||
const objectInfo = await getSqlObjectInfo(props);
|
const objectInfo = await getSqlObjectInfo(props);
|
||||||
if (objectInfo) {
|
if (objectInfo) {
|
||||||
if (objectInfo.requiresFormat) setSql(sqlFormatter.format(objectInfo.createSql));
|
if (objectInfo.requiresFormat && objectInfo.createSql) setSql(sqlFormatter.format(objectInfo.createSql));
|
||||||
else setSql(objectInfo.createSql);
|
else setSql(objectInfo.createSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user