1
1
mirror of https://github.com/Fabio286/antares.git synced 2024-12-26 00:33:02 +01:00

feat: triggers and stored routines in sql suggestions

This commit is contained in:
Fabio Di Stasio 2021-01-07 18:22:49 +01:00
parent 6e55f27b23
commit e351c903a8
2 changed files with 41 additions and 5 deletions

View File

@ -47,13 +47,40 @@ export default {
}, []).map(table => {
return {
name: table.name,
comment: table.comment,
type: table.type,
fields: []
};
})
: [];
},
triggers () {
return this.workspace
? this.workspace.structure.filter(schema => schema.name === this.schema)
.reduce((acc, curr) => {
acc.push(...curr.triggers);
return acc;
}, []).map(trigger => {
return {
name: trigger.name,
type: 'trigger'
};
})
: [];
},
procedures () {
return this.workspace
? this.workspace.structure.filter(schema => schema.name === this.schema)
.reduce((acc, curr) => {
acc.push(...curr.procedures);
return acc;
}, []).map(procedure => {
return {
name: `${procedure.name}()`,
type: 'routine'
};
})
: [];
},
mode () {
switch (this.workspace.client) {
case 'mysql':
@ -130,11 +157,14 @@ export default {
this.editor.completers.push({
getCompletions: (editor, session, pos, prefix, callback) => {
const completions = [];
this.tables.forEach(table => {
[
...this.tables,
...this.triggers,
...this.procedures
].forEach(el => {
completions.push({
value: table.name,
meta: table.type,
caption: table.comment
value: el.name,
meta: el.type
});
});
callback(null, completions);

View File

@ -1239,6 +1239,12 @@ ace.define('ace/autocomplete/popup', ['require', 'exports', 'module', 'ace/virtu
case 'view':
iconClass = 'mdi-table-eye';
break;
case 'trigger':
iconClass = 'mdi-table-cog';
break;
case 'routine':
iconClass = 'mdi-sync-circle';
break;
case 'keyword':
iconClass = 'mdi-cube';
break;