mirror of
https://github.com/Fabio286/antares.git
synced 2024-12-25 08:20:39 +01:00
feat: triggers and stored routines in sql suggestions
This commit is contained in:
parent
6e55f27b23
commit
e351c903a8
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user