Skip to content

Commit

Permalink
feat: triggers and stored routines in sql suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Jan 7, 2021
1 parent 6e55f27 commit e351c90
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/renderer/components/QueryEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/libs/ext-language_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e351c90

Please sign in to comment.